λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
CSS/Animation

μ• λ‹ˆλ©”μ΄μ…˜ 효과 _ λ¬΄ν•œλŒ€ 곡

by oranssy 2022. 9. 5.
728x90
λ°˜μ‘ν˜•

⭐️ μ• λ‹ˆλ©”μ΄μ…˜ 효과 : λ¬΄ν•œλŒ€λ‘œ νŠ€λŠ” 곡 ⭐️


01. μ• λ‹ˆλ©”μ΄μ…˜ 효과

μ• λ‹ˆλ©”μ΄μ…˜(Animation) νš¨κ³ΌλŠ” HTML μš”μ†Œμ— μ μš©λ˜λŠ” CSS μŠ€νƒ€μΌμ„ λ‹€λ₯Έ CSS μŠ€νƒ€μΌλ‘œ λΆ€λ“œλŸ½κ²Œ λ³€ν™”μ‹œν‚΅λ‹ˆλ‹€.
μ• λ‹ˆλ©”μ΄μ…˜μ€ μ• λ‹ˆλ©”μ΄μ…˜μ„ λ‚˜νƒ€λ‚΄λŠ” CSS μŠ€νƒ€μΌκ³Ό μ• λ‹ˆλ©”μ΄μ…˜μ˜ μ—°μ†λœ μž₯λ©΄(sequence)λ₯Ό λ‚˜νƒ€λ‚΄λŠ” 볡수의 ν‚€ν”„λ ˆμž„(@keyframes)λ“€λ‘œ μ΄λ£¨μ–΄μ§‘λ‹ˆλ‹€.

   ___ μ°Έκ³ ν•˜κΈ° ___
  `1   @keyframes : CSS μ• λ‹ˆλ©”μ΄μ…˜μ—μ„œ ꡬ간을 μ •ν•˜κ³  각 κ΅¬κ°„λ³„λ‘œ μ–΄λ–€ μŠ€νƒ€μΌμ„ μ μš©μ‹œν‚¬μ§€ μ •ν•©λ‹ˆλ‹€.


02. λ¬΄ν•œλŒ€ λͺ¨μ–‘μœΌλ‘œ νŠ€λŠ” 곡

[1] < div > λ°•μŠ€ λ§Œλ“€κΈ°

div μ•ˆμ— div κ°€ μžˆλŠ” ꡬ쑰λ₯Ό 5개 λ§Œλ“€μ–΄ μ€λ‹ˆλ‹€.

<div class="wrapper">
<div></div>
</div>
<div class="wrapper">
<div></div>
</div>
<div class="wrapper">
<div></div>
</div>
<div class="wrapper">
<div></div>
</div>
<div class="wrapper">
<div></div>
</div>

[2] CSS μ„€μ •ν•˜κΈ°

@keyframes 을 μ΄μš©ν•˜μ—¬ μ• λ‹ˆλ©”μ΄μ…˜μ˜ μ›€μ§μž„μ„ μ‘°μ ˆν•©λ‹ˆλ‹€.

* {
box-sizing: border-box;
}
body {
background: linear-gradient(to top, #A18CD1 0%, #FBC2EB 100%);
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
}
.wrapper {
position: absolute;
animation: x 1s ease-in-out alternate infinite 0s both;
}
.wrapper:nth-of-type(2) {
animation-delay: 0.1s;
}
.wrapper:nth-of-type(3) {
animation-delay: 0.2s
}
.wrapper:nth-of-type(4) {
animation-delay: 0.3s
}
.wrapper:nth-of-type(5) {
animation-delay: 0.4s
}
.wrapper > div {
width: 50px;
height: 50px;
background-color: #fff;
border-radius: 100%;
margin: 40px;
animation: y 1s linear infinite 0s both;
}
.wrapper:nth-of-type(2) > div {
animation-delay: 0.1s;
height: 40px;
width: 40px;
opacity: 0.8;
}
.wrapper:nth-of-type(3) > div {
animation-delay: 0.2s;
height: 40px;
width: 40px;
opacity: 0.6;
}
.wrapper:nth-of-type(4) > div {
animation-delay: 0.3s;
height: 40px;
width: 40px;
opacity: 0.4;
}
.wrapper:nth-of-type(5) > div {
animation-delay: 0.4s;
height: 40px;
width: 40px;
opacity: 0.2;
}
@keyframes x {
0% {
transform:translatex(-100px);
}
100% {
transform:translatex(100px);
}
}
@keyframes y {
25% {
transform:translatey(-50px);
}
0%,50%,100% {
transform:translatey(0);
}
75% {
transform:translatey(50px);
}
}

결과보기

728x90
λ°˜μ‘ν˜•

λŒ“κΈ€