分类分类
更新时间:2026-02-18 21:23:09作者:zy
本文给大家分享基于css实现毛毛虫爬行动作,需要的朋友参考下吧!
毛毛虫儿时大家都有见过,今天想起来写一个爬行的动作,具体代码如下所示:

html代码:
<div class='container'>
<div class='hide left'></div>
<div class='hide right'></div>
<div class='hide bottom'></div>
<div class='circle-container'>
<div class='circle'></div>
</div>
</div>
css代码:
<style>
body {
background-color: #1B6CB2;
margin: 0;
}
.container {
position: absolute;
width: 600px;
height: 400px;
overflow: hidden;
top: 50%;
left: 60%;
transform: translate(-50%, -50%);
}
.hide {
height: 100%;
width: 150px;
background: #1B6CB2;
position: absolute;
z-index: 2;
}
.hide.left {
left: 0;
}
.hide.right {
right: 0;
}
.hide.bottom {
bottom: 0;
width: 100%;
height: 50%;
}
.circle {
position: absolute;
height: 75px;
width: 150px;
border: 3px solid white;
border-radius: 50%/100% 100% 0 0;
border-bottom: none;
top: 40%;
left: 50%;
transform-origin: 0% 50%;
transform: translate(-50%, -50%);
animation: magic 1.8s ease infinite;
}
@keyframes magic {
0% { transform: rotate(-170deg) translate(-50%, -50%); }
50% { transform: rotate(0deg) translate(-50%, -50%); }
100% { transform: rotate(180deg) translate(-50%, -50%);}
}
.circle-container {
position: absolute;
height: 75px;
width: 150px;
top: 40%;
left: 50%;
transform-origin: 0% 50%;
transform: translate(-50%, -50%);
animation: power 1.8s ease-out infinite;
}
@keyframes power {
0% { margin-left: 20px; }
50% { margin-left: -55px; }
99.9% { margin-left: -130px; }
100% { margin-left: 20px; }
}
</style>
总结
以上所述是小编给大家介绍的css实现毛毛虫爬行动作,希望对大家有所帮助。
相关
归墟战纪策略游戏262.92 MBv3.95802026-02-14
下载爆裂老奶策略游戏209.43 MBv1.0.112026-02-14
下载超能下蛋鸭策略游戏395.4 MBv1.2.82026-02-14
下载你好盒子实用工具12.1 MBv2.2.852026-02-14
下载我在峡谷当牛马休闲益智87.95 MBv0.7.12026-02-14
下载抽卡监狱2策略游戏190.75 MBv1.4.92026-02-14
下载Campus社交通讯94.36 MBv1.19.02026-02-14
下载冒险传奇角色扮演141.73 Mv9991.12026-02-14
下载心动次元app社交通讯43.96 Mv1.0.1.32026-02-14
下载致亲爱的我角色扮演1.63Gv1.02026-02-14
下载狼伴侣游戏手机版冒险游戏155.6 Mv1.02026-02-14
下载Loclike社交通讯169.08 Mv2.2.112026-02-14
下载










