CSS 动画一站式指南目录CSS 动画一站式指南1. CSS 动画1.1 变换 1.1.1 变换属性介绍 1.1.2 变换动画实践1.2 过渡 1.2.1 过渡属性介绍 1.2.2 过渡动画实践1.3
顺晟科技
2021-06-28 19:46:03
208
clip-path的超强应用: http://species-in-pieces.com/
(最后抖了一下是gif没录制好不是动画的问题)
HTML
<div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
CSS
.wrapper {
width: 500px;
height: 500px;
position: relative;
background-color: #f0f0f0;
margin: auto;
}
.piece {
position: absolute;
width: ;
height: ;
left: 0;
right: 0;
top: 0;
bottom: 0;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-delay: 1s;
animation-fill-mode: both;
animation-timing-function: cubic-bezier(0.62, 0.02, 0.34, 1);
}
.piece:nth-child(1) {
animation-name: move1;
}
.piece:nth-child(2) {
animation-name: move2;
}
.piece:nth-child(3) {
animation-name: move3;
}
.piece:nth-child(4) {
animation-name: move4;
}
@keyframes move1{
0%, 10% {
background: #368AE4;
clip-path: polygon(100px 100px, 200px 100px, 150px 186.60px);
}
90%, {
background: linear-gradient(180deg, #368AE4, #e400c6);
clip-path: polygon(150px 150px, 150px 350px, 250px 250px);
}
}
@keyframes move2{
0%, 10% {
background: #ff5500;
clip-path: polygon(350px 100px, 300px 186.60px, 400px 186.60px);
}
90%, {
background: linear-gradient(180deg, #ffaa7f, #4be47e);
clip-path: polygon(150px 150px, 350px 150px, 250px 250px);
}
}
@keyframes move3{
0%, 10% {
background: #55007f;
clip-path: polygon(100px 300px, 200px 300px, 150px 386.60px);
}
90%, {
background: linear-gradient(180deg, #3401ff, #e46c09);
clip-path: polygon(350px 150px, 350px 350px, 250px 250px);
}
}
@keyframes move4{
0%, 10% {
background: #7f1e6d;
clip-path: polygon(350px 300px, 300px 386.60px, 400px 386.60px);
}
90%, {
background: linear-gradient(180deg, #f4ff10, #dc60e4);
clip-path: polygon(150px 350px, 350px 350px, 250px 250px);
}
}
主要思路,每一个片都是一个完整的填满最外层容器的div,使用clip-path画出三角形,动画改变三角形的位置
09
2022-11
09
2022-11
15
2022-09
15
2022-09
15
2022-09
14
2022-09