whatisthis?
CSS - Animation practice ๋ณธ๋ฌธ
CSS - Animation practice
๐ป ๋ด๊ฐ ์์ฑํ ์ฝ๋
* {
box-sizing: border-box;
margin: 0;
}
body {
font-family: "Mulish", sans-serif;
}
.loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 80px 100px;
}
.loading-title {
color: #151b26;
font-size: 18px;
line-height: 1.33333333;
margin-bottom: 20px;
animation-name: loading-effect;
animation-duration: 1000ms;
animation-iteration-count: infinite;
animation-timing-function: ease-in;
}
.progress-bar {
position: relative;
background-color: #e5eaef;
width: 300px;
height: 12px;
border-radius: 100px;
}
.progress-bar-gauge {
position: absolute;
top: 0;
left: 0;
background-color: #13ce66;
width: 0;
height: 12px;
border-radius: 30px;
animation-name: loading-progress;
animation-iteration-count: infinite;
animation-duration: 2000ms;
animation-delay: 500ms;
}
@keyframes loading-progress {
from {
width: 0;
}
to {
width: 100%;
}
}
@keyframes loading-effect {
from {
color: #151b26;
}
to {
color: #fff;
}
}
border-radius ์ค์ ๋๊ทธ๋๊ฒ ๋ง๋ค ๋,
50%๋ฅผ ์ค์์๋๊ฑด ์์๊ฐ ์ ์ฌ๊ฐํ์ผ๋๋ง ๊ฐ๋ฅ.
๋๋จธ์ง๋ ๊ทธ๋ฅ px์ ํฌ๊ฒ ์ค์ผํจ.
+) ๊ฐ์๋ด์ฉ ์ถ๊ฐ
.progress-bar {
overflow: hidden;
}
์ด๋ ๊ฒ overflow:hidden์ ํด์
๊ฒ์ด์ง๊ฐ ๋ง์ฝ width๊ฐ ๋์ด๊ฐ๋ ์๋ณด์ด๊ฒ ํด์ค ์ ์์.
** ํ์ดํ ๊ธ์ ๊น๋นก์ด๊ฒ ํ๊ธฐ
- ๋๋ color: #fff๋ก ๋ฐ๋๊ฒ ํ๋๋ฐ,
์ฌ๊ธฐ์๋ ๊ทธ๋ฅ ํฌ๋ช ๋(opacity)๋ฅผ ์ค์
1(๋ถํฌ๋ช ) -> 0(ํฌ๋ช )ํ๊ฒ ํด์ฃผ์๋ค.
@keyframes flicker {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
+) animation-direction : alternate๋ฅผ ์ค์ ์ข๋ ์์ฐ์ค๋ฝ๊ฒ.
animation-direction: alternate;
alternate
์ ๋๋ฉ์ด์ ์ ๋งค ์ฌ์ดํด๋ง๋ค ๊ฐ ์ฃผ๊ธฐ์ ๋ฐฉํฅ์ ๋ค์ง์ผ๋ฉฐ, ์ฒซ ๋ฒ์งธ ๋ฐ๋ณต์ ์ ๋ฐฉํฅ์ผ๋ก ์งํ๋ฉ๋๋ค.
์ฌ์ดํด์ด ์ง์์ธ์ง ํ์์ธ์ง๋ฅผ ๊ฒฐ์ ํ๋ ์นด์ดํธ๊ฐ ํ๋์์ ์์๋ฉ๋๋ค.
+) ๋ก๋ฉ ์ ๋๋ฉ์ด์ ์์
@keyframes loading-progress {
0% {
width: 0;
opacity: 1;
}
80% {
width: 100%;
opacity: 1;
}
100% {
width: 100%;
opacity: 0;
}
}
๐ป(์์ ) ์ ์ฒด ์ฝ๋
* {
box-sizing: border-box;
margin: 0;
}
body {
font-family: "Mulish", sans-serif;
background-color: #fafafa;
}
.loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 80px 100px;
background-color: #fff;
}
.loading-title {
color: #151b26;
font-size: 18px;
line-height: 1.33333333;
margin-bottom: 20px;
animation-name: flicker;
animation-duration: 1600ms;
animation-iteration-count: infinite;
animation-direction: alternate;
}
.progress-bar {
position: relative;
background-color: #e5eaef;
width: 300px;
height: 12px;
border-radius: 100px;
overflow: hidden;
}
.progress-bar-gauge {
position: absolute;
top: 0;
left: 0;
background-color: #13ce66;
width: 0;
height: 12px;
border-radius: 30px;
animation-name: loading-progress;
animation-iteration-count: infinite;
animation-duration: 2000ms;
animation-timing-function: ease-out;
}
@keyframes loading-progress {
0% {
width: 0;
opacity: 1;
}
80% {
width: 100%;
opacity: 1;
}
100% {
width: 100%;
opacity: 0;
}
}
@keyframes flicker {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
ref lecture.
- https://edu.goorm.io/learn/lecture/20583
- https://github.com/rohjs/bugless-101/tree/master/css-basic/transition/templates
'PRACTICE > SELF' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
practice - css / jquery ) j์ฟผ๋ฆฌ๋ก ์์ฝ๋์ธ๋ฉ๋ด ๋ง๋ค๊ธฐ (0) | 2022.03.10 |
---|---|
practice - css / js ) j์ฟผ๋ฆฌ ์์ด ์์ฝ๋์ธ๋ฉ๋ด ๋ง๋ค๊ธฐ (0) | 2022.03.10 |
CSS - Transition practice (1) | 2022.03.01 |
CSS - Background practice (AirBnB card) (0) | 2022.02.28 |
CSS - Typography Library ์ ์ (prac) (0) | 2022.02.28 |