纯css实现一个老鼠转轮子动画效果
代码语言:html
所属分类:动画
代码描述:纯css实现一个老鼠转轮子动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> :root { --wheel-color: #01827F; --hamster-color: #F4B874; } body{ background: lightgray; } .box-canvas{ position: relative; margin: auto; display: block; margin-top: 8%; margin-bottom: 8%; width: 170px; height:200px; } .wheel-leg { width: 10px; height: 30px; background: #80CBC4; position: absolute; bottom: 20px; } .wheel-leg.left { left: 15px; -webkit-transform: rotate(25deg); transform: rotate(25deg); } .wheel-leg.right { right: 15px; -webkit-transform: rotate(-25deg); transform: rotate(-25deg); } .wheel { position: absolute; width: 150px; height: 150px; border: 10px solid var(--wheel-color); border-radius: 50%; background: conic-gradient( var(--wheel-color), var(--wheel-color) 5deg, transparent 5deg, transparent 60deg, var(--wheel-color) 60deg, var(--wheel-color) 65deg, transparent 65deg, transparent 120deg, var(--wheel-color) 120deg, var(--wheel-color) 125deg, transparent 125deg, transparent 180deg, var(--wheel-color) 180deg, var(--wheel-color) 185deg, transparent 185deg, transparent 240deg, var(--wheel-color) 240deg, var(--wheel-color) 245deg, transparent 245deg, transparent 300deg, var(--wheel-color) 300deg, var(--wheel-color) 305deg, transparent 305deg ); -webkit-animation: spinWheel 1s infinite linear; animation: spinWheel 1s infinite linear; } @-webkit-keyframes spinWheel { 0% { -webkit-transform: none; transform: none; } 100% { -webkit-transform: rotate(-360deg); transform: rotate(-360deg); } } @keyframes spinWheel { 0% { -webkit-transform: none; transform: none; } 100% { -webkit-transform: rotate(-360deg); transform: rotate(-360deg); } } .wheel::before { content: ''; position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); width: 25px; height: 25px; border-radius: 50%; background: #80CBC4; } .wheel::after { content: ''; position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); width: 170px; height: 170px; border: 5px solid #80CBC4; border-radius: 50%; } .hamster { position: absolute; top: 102px; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); width: 75px; height: 50px; } .body { width: 75px; height: 40px; position: absolute; bottom: 0; background: var(--hamster-color); -webkit-transform: rotate(10deg); transform: rotate(10deg); border-radius: 50% / 60% 60% 40% 40%; overflow: hidden; } .body::before { content: ''; position: absolute; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); width: 50px; height: 25px; background: #F2CEA4; bottom: -12px; border-radius: 50%; } .ear { position: absolute; l.........完整代码请登录后点击上方下载按钮下载查看
网友评论0