css布局实现一个蚂蚱交互动画效果代码
代码语言:html
所属分类:动画
代码描述:css布局实现一个蚂蚱交互动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { align-content: center; background: #9b7653; cursor: crosshair; display: grid; grid-template-columns: 1fr auto auto 1fr; grid-template-rows: 1fr auto auto 1fr; justify-content: center; margin: 0; overflow: hidden; padding: 0; width: 100vw; height: 100vh; } #mantis { grid-area: 2/2/4/4; position: relative; } #mantis .head { background: #74c365; border-radius: 50%; position: relative; top: 4vmin; left: 8vmin; transform: rotate(25deg); transition: transform 100ms, top 100ms, left 100ms; width: 8vmin; height: 3vmin; z-index: 2; } #mantis .head::before, #mantis .head::after { background: inherit; border-radius: 50%; content: ""; display: block; position: absolute; } #mantis .head::before { background: linear-gradient(#85ca77, #85ca77 10%, #74c365 10%); bottom: 0.1vmin; left: -0.3vmin; transform: rotate(18deg); width: 66%; height: 200%; } #mantis .head::after { bottom: 1.75vmin; left: 0.5vmin; transform: rotate(35deg); width: 100%; height: 100%; } #mantis .head .eye { background: #85ca77; border-radius: 50% 50% 50% 33%; position: absolute; bottom: 0; left: -0.25vmin; transform: rotate(20deg); width: 5vmin; height: 4vmin; z-index: 1; } #mantis .head .eye::after { -webkit-animation: moveeye 10s infinite; animation: moveeye 10s infinite; background: black; border-radius: 50%; content: ""; position: absolute; bottom: 2vmin; left: 3.5vmin; transition: bottom 100ms, left 100ms; width: 0.5vmin; height: 0.5vmin; } #mantis .head .antennae { position: relative; z-index: 1; } #mantis .head .antennae::before, #mantis .head .antennae::after { border-left: 0.5vmin solid #74c365; border-radius: 50% 0 0 0; content: ""; display: block; position: absolute; width: 10vmin; height: 15vmin; } #mantis .head .antennae::before { bottom: -0.75vmin; left: 4.5vmin; transform: rotate(20deg); } #mantis .head .antennae::after { bottom: -1.25vmin; left: 5.5vmin; transform: rotate(30deg); } #mantis .body { background: #74c365; border-radius: 50%; position: relative; transform: rotate(33deg); width: 5vmin; height: 25vmin; z-index: 1; } #mantis .body::after { background: inherit; border-radius: 50%; content: ""; display: block; position: absolute; top: 20vmin; left: -12.5vmin; transform: rotate(33deg); width: 10vmin; height: 40vmin; } #mantis .body .front-leg { border-radius: 0 0 50% 50%; position: relative; width: 2vmin; height: 15vmin; } #mantis .body .front-leg::before, #mantis .body .front-leg::after { background: inherit; content: ""; position: absolute; } #mantis .body .front-leg::before { border-radius: 25% 25% 50% 50%; right: -7.5vmin; bottom: -5.25vmin; transform: rotate(-100deg); width: 3vmin; height: 15vmin; } #mantis .body .front-leg::after { border-radius: 0 50% 50% 50%; right: -9vmin; bottom: -9.75vmin; transform: rotate(40deg); width: 1vmin; height: 15vmin; } #mantis .body .front-leg.left { background: linear-gradient(#74c365, #74c365 22%, #63bc53 40%); top: 0; left: 8vmin; transform: rotate(-66deg); } #mantis .body .front-leg.left::before, #mantis .body .front-leg.left::after { background: #63bc53; } #mantis .body .front-leg.left:hover { top: -2vmin; transform: rotate(-86deg); } #mantis .body .front-leg.right { background: inherit; top: -12.75vmin; left: 7vmin; transform: rotate(-50deg); } #mantis .body .front-leg.right:hover { top: -14vmin; transform: rotate(-70deg); } #mantis .body .middle-legs, #mantis .body .rear-leg { background: inherit; border-radius: 0 0 50% 50%; box-shadow: 1.5vmin -1vmin 0 #63bc53; position: relative; top: -5.5vmin; left: 3vmin; transform: rotate(-35deg); width: 1vmin; height: 10vmin; } #mantis .body .middle-legs::before, #mantis .body .rear-leg::before, #mantis .body .middle-legs::after, #mantis .body .rear-leg::after { background: inherit; border-radius: 33%; content: ""; position: absolute; width: 1vmin; height: 12vmin; } #mantis .body .middle-legs::before, #mantis .body .rear-leg::before { box-sha.........完整代码请登录后点击上方下载按钮下载查看
网友评论0