css实现一个非常饿的毛毛虫效果代码
代码语言:html
所属分类:动画
代码描述:css实现一个非常饿的毛毛虫效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { display: grid; width: 100vw; height: 100vh; place-items: center; } body #caterpillar { width: 400px; height: 400px; } body #caterpillar .segment { offset-path: path("M 60 270 C 140 290 120 200 200 200 C 280 200 240 290 360 270 "); position: absolute; width: 50px; height: 70px; border-radius: 100px/115px; offset-rotate: auto; -webkit-animation: wiggle 3s ease-in-out infinite alternate; animation: wiggle 3s ease-in-out infinite alternate; } body #caterpillar .segment .inner { position: absolute; width: 100%; height: 100%; border-radius: inherit; } body #caterpillar .segment:nth-of-type(9) .legs, body #caterpillar .segment:nth-of-type(10) .legs, body #caterpillar .segment:first-of-type .legs { content: ""; position: absolute; bottom: -15px; filter: none; left: 25px; width: 15px; height: 15px; } body #caterpillar .segment:nth-of-type(9) .legs:before, body #caterpillar .segment:nth-of-type(9) .legs:after, body #caterpillar .segment:nth-of-type(10) .legs:before, body #caterpillar .segment:nth-of-type(10) .legs:after, body #caterpillar .segment:first-of-type .legs:before, body #caterpillar .segment:first-of-type .legs:after { content: ""; position: absolute; width: 100%; height: 100%; left: 0; top: 0; -webkit-clip-path: polygon(20% 0, 24% 44%, 100% 53%, 100% 92%, 25% 100%, 0 96%, 0 0); clip-path: polygon(20% 0, 24% 44%, 100% 53%, 100% 92%, 25% 100%, 0 96%, 0 0); background: #37501e; transform-origin: top; z-index: 1; -webkit-animation: walk 0.75s ease-in-out infinite alternate; animation: walk 0.75s ease-in-out infinite alternate; transform: rotate(-10deg); } @-webkit-keyframes walk { to { transform: rotate(10deg); } } @keyframes walk { to { transform: rotate(10deg); } } body #caterpillar .segment:nth-of-type(9) .legs:after, body #caterpillar .segment:nth-of-type(10) .legs:after, body #caterpillar .segment:first-of-type .legs:after { left: 20px; top: -5px; width: 90%; background: #1e2b10; z-index: 0; } body #caterpillar .segment:first-of-type .legs { bottom: -12.5px; left: 12.5px; transform: scale(0.9); } body #caterpillar .segment:nth-of-type(1) { offset-distance: 0%; width: 42px; height: 77px; } body #caterpillar .segment:nth-of-type(1) .legs:before { -webkit-animation-delay: -0.25s; animation-delay: -0.25s; } body #caterpillar .segment:nth-of-type(1) .legs:after { -webkit-animation-delay: 0s; animation-delay: 0s; } body #caterpillar .segment:nth-of-type(2) { offset-distance: 10%; width: 44px; height: 79px; } body #caterpillar .segment:nth-of-type(2) .legs:before { -webkit-animation-delay: -0.5s; animation-delay: -0.5s; } body #caterpillar .segment:nth-of-type(2) .legs:after { -webkit-animation-delay: -0.25s; animation-delay: -0.25s; } body #caterpillar .segment:nth-of-type(3) { offset-distance: 20%; width: 46px; height: 81px; } body #caterpillar .segment:nth-of-type(3) .legs:before { -webkit-animation-delay: -0.75s; animation-delay: -0.75s; } body #caterpillar .segment:nth-of-type(3) .legs:after { -webkit-animation-delay: -0.5s; animation-delay: -0.5s; } body #caterpillar .segment:nth-of-type(4) { offset-distance: 30%; width: 48px; height: 83px; } body #caterpillar .segment:nth-of-type(4) .legs:before { -webkit-animation-delay: -1s; animation-delay: -1s; } body #caterpillar .segment:nth-of-type(4) .legs:after { -webkit-animation-delay: -0.75s; animation-delay: -0.75s; } body #caterpillar .segment:nth-of-type(5) { offset-distance: 40%; width: 50px; height: 85px; } body #caterpillar .segment:nth-of-type(5) .legs:before { -webkit-animation-delay: -1.25s; animation-delay: -1.25s; } body #caterpillar .segment:nth-of-type(5) .legs:after { -webkit-animation-delay: -1s; animation-delay: -1s; } body #caterpillar .segment:nth-of-type(6) { offset-distance: 50%; width: 52px; height: 87px; } body #caterpillar .segment:nth-of-type(6) .legs:before { -webkit-animation-delay: -1.5s; animation-delay: -1.5s; } body #caterpillar .segment:nth-of-type(6) .legs:after { -webkit-animation-delay: -1.25s; animation-delay: -1.25s; } body #caterpillar .segment:nth-of-type(7) { offset-distance: 60%; width: 54px; height: 89px; } body #caterpillar .segment:nth-of-type(7) .legs:before { -webkit-animation-delay: -1.75s; animation-delay: -1.75s; } body #caterpillar .segment:nth-of-type(7) .legs:after { -webkit-animation-delay: -1.5s; animation-delay: -1.5s; } body #caterpillar .segment:nth-of-type(8) { offset-distance: 70%; width: 56px; height: 91px; } body #caterpillar .segment:nth-of-type(8) .legs:before { -webkit-animation-delay: -2s; animation-delay: -2s; } body #caterpillar .segment:nth-of-type(8) .legs:after { -webkit-animation-delay: -1.75s; animation-delay: -1.75s; } body #caterpillar .segment:nth-of-type(9) { offset-distance: 80%; width: 58px; height: 93px; } body #caterpillar .segment:nth-of-type(9) .legs:before { -webkit-animation-delay: -2.25s; animation-delay: -.........完整代码请登录后点击上方下载按钮下载查看
网友评论0