css实现三维齿轮旋转动画效果代码

代码语言:html

所属分类:三维

代码描述:css实现三维齿轮旋转动画效果代码

代码标签: 齿轮 旋转 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">






    <style>
        *, *::before, *::after {
          padding: 0;
          margin: 0 auto;
          box-sizing: border-box;
        }
        
        body {
          background-color: #111;
          color: #fff;
          min-height: 100vh;
          display: grid;
          place-items: center;
          font-size: 10px;
          perspective: 500px;
          overflow: hidden;
        }
        
        *:not(:empty) {
          transform-style: preserve-3d;
        }
        
        .gears {
          position: relative;
          -webkit-animation: sceneRotate 30s infinite linear;
                  animation: sceneRotate 30s infinite linear;
        }
        @-webkit-keyframes sceneRotate {
          0% {
            transform: rotateY(0deg);
          }
          50% {
            transform: rotateY(-180deg);
          }
          100% {
            transform: rotateY(-360deg);
          }
        }
        @keyframes sceneRotate {
          0% {
            transform: rotateY(0deg);
          }
          50% {
            transform: rotateY(-180deg);
          }
          100% {
            transform: rotateY(-360deg);
          }
        }
        
        .gear {
          position: absolute;
          -webkit-animation: gearRotate 30s infinite linear;
                  animation: gearRotate 30s infinite linear;
        }
        @-webkit-keyframes gearRotate {
          0% {
            transform: rotate(0deg);
          }
          100% {
            transform: rotate(-360deg);
          }
        }
        @keyframes gearRotate {
          0% {
            transform: rotate(0deg);
          }
          100% {
            transform: rotate(-360deg);
          }
        }
        
        .tooth {
          position: absolute;
          left: 0;
          bottom: 0;
          height: 27.5em;
          transform-origin: bottom;
          transform: rotateZ(var(--angle, 0deg));
        }
        .tooth:nth-child(1) {
          --angle: 0deg;
        }
        .tooth:nth-child(2) {
          --angle: 6deg;
        }
        .tooth:nth-child(3) {
          --angle: 12deg;
        }
        .tooth:nth-child(4) {
          --angle: 18deg;
        }
        .tooth:nth-child(5) {
          --angle: 24deg;
        }
        .tooth:nth-child(6) {
          --angle: 30deg;
        }
        .tooth:nth-child(7) {
          --angle: 36deg;
        }
        .tooth:nth-child(8) {
          --angle: 42deg;
        }
        .tooth:nth-child(9) {
          --angle: 48deg;
        }
        .tooth:nth-child(10) {
          --angle: 54deg;
        }
        .tooth:nth-child(11) {
          --angle: 60deg;
        }
        .tooth:nth-child(12) {
          --angle: 66deg;
        }
        .tooth:nth-child(13) {
          --angle: 72deg;
        }
        .tooth:nth-child(14) {
          --angle: 78deg;
        }
        .tooth:nth-child(15) {
          --angle: 84deg;
        }
        .tooth:nth-child(16) {
          --angle: 90deg;
        }
        .tooth:nth-child(17) {
          --angle: 96deg;
        }
        .tooth:nth-child(18) {
          --angle: 102deg;
        }
        .tooth:nth-child(19) {
          --angle: 108deg;
        }
        .tooth:nth-child(20) {
          --angle: 114deg;
        }
        .tooth:nth-child(21) {
          --angle: 120deg;
        }
        .tooth:nth-child(22) {
          --angle: 126deg;
        }
        .tooth:nth-child(23) {
          --angle: 132deg;
        }
        .tooth:nth-child(24) {
          --angle: 138deg;
        }
        .tooth:nth-child(25) {
          --angle: 144deg;
        }
        .tooth:nth-child(26) {
          --angle: 150deg;
        }
        .tooth:nth-child(27) {
          --angle: 156deg;
        }
        .tooth:nth-child(28) {
          --angle: 162deg;
        }
        .tooth:nth-child(29) {
          --angle: 168deg;
        }
        .tooth:nth-child(30) {
          --angle: 174deg;
        }
        .tooth:nth-child(31) {
          --angle: 180deg;
        }
        .tooth:nth-child(32) {
          --angle: 186deg;
        }
        .tooth:nth-child(33) {
          --angle: 192deg;
        }
        .tooth:nth-child(34) {
          --angle: 198deg;
        }
        .tooth:nth-child(35) {
          --angle: 204deg;
        }
        .tooth:nth-child(36) {
          --angle: 210deg;
        }
        .tooth:nth-child(37) {
          --angle: 216deg;
        }
        .tooth:nth-child(38) {
          --angle: 222deg;
        }
        .tooth:nth-child(39) {
          --angle: 228deg;
        }
        .tooth:nth-child(40) {
          --angle: 234deg;
        }
        .tooth:nth-child(41) {
          --angle: 240deg;
        }
        .tooth:nth-child(42) {
          --angle: 246deg;
        }
        .tooth:nth-child(43) {
          --angle: 252deg;
        }
        .tooth:nth-child(44) {
          --angle: 258deg;
        }
        .tooth:nth-child(45) {
          --angle: 264deg;
        }
        .tooth:nth-child(46) {
          --angle: 270deg;
        }
        .tooth:nth-child(47) {
          --angle: 276deg;
        }
        .tooth:nth-child(48) {
          --angle: 282deg;
        }
        .tooth:nth-child(49) {
          --angle: 288deg;
        }
        .tooth:nth-child(50) {
          --angle: 294deg;
        }
        .tooth:nth-child(51) {
          --angle: 300deg;
        }
        .tooth:nth-child(52) {
          --angle: 306deg;
        }
        .tooth:nth-child(53) {
          --angle: 312deg;
        }
        .tooth:nth-child(54) {
          --angle: 318deg;
        }
        .tooth:nth-child(55) {
          --angle: 324deg;
        }
        .tooth:nth-child(56) {
          --angle: 330deg;
        }
        .tooth:nth-child(57) {
          --angle: 336deg;
        }
        .tooth:nth-child(58) {
          --angle: 342deg;
        }
        .tooth:nth-child(59) {
          --angle: 348deg;
        }
        .tooth:nth-child(60) {
          --angle: 354deg;
        }
        .tooth > * {
          position: absolute;
          h.........完整代码请登录后点击上方下载按钮下载查看

网友评论0