728x90
애니메이션 만들기
css 애니메이션을 만들어 봅니다!
애니메이션 : 움직이는 공
잔상이 뒤따르는 움직이는 공 애니메이션을 만들어 봅니다.
* {
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: #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: 30px;
width: 30px;
opacity: 0.6;
}
.wrapper:nth-of-type(4) > div {
animation-delay: 0.3s;
height: 20px;
width: 20px;
opacity: 0.4;
}
.wrapper:nth-of-type(5) > div {
animation-delay: 0.4s;
height: 10px;
width: 10px;
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)}
}
See the Pen 공 움직이는 애니메이션 by hjkang306 (@hjkang306) on CodePen.
728x90
'CSS > 애니메이션' 카테고리의 다른 글
CSS 애니메이션 : 꾸물거리는 점 (5) | 2022.09.19 |
---|---|
CSS 애니메이션 : SVG 만들기와 SVG 애니메이션 (8) | 2022.09.07 |
CSS 애니메이션 : 속성 알아보기 + 예제 (7) | 2022.09.07 |
CSS 애니메이션 : 로딩 동그라미 (1) | 2022.09.02 |
CSS 애니메이션 : 구르는 박스 (1) | 2022.09.02 |
댓글