css布局实现六边形网状球体类似足球旋转伸缩动画效果代码

代码语言:html

所属分类:动画

代码描述:采用css布局实现一个六边形网状球体,有点类似足球的形状自转并做伸缩运动的动画效果代码

代码标签: 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 {
      min-height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
      perspective: 1125px;
      background-image: radial-gradient(circle, #000, #222);
    }
    
    .ball {
      position: relative;
      transform-style: preserve-3d;
      -webkit-animation: ball 60s infinite linear;
              animation: ball 60s infinite linear;
      --rx: 0deg;
      --ry: 0deg;
    }
    @-webkit-keyframes ball {
      from {
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
      }
      to {
        transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg);
      }
    }
    @keyframes ball {
      from {
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
      }
      to {
        transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg);
      }
    }
    .ball > :nth-child(1) {
      -webkit-animation-delay: -2.475s;
              animation-delay: -2.475s;
      -webkit-animation-duration: 4.7s;
              animation-duration: 4.7s;
    }
    .ball > :nth-child(1)::before {
      background-color: #8547ff;
    }
    .ball > :nth-child(2) {
      -webkit-animation-delay: -4.05s;
              animation-delay: -4.05s;
      -webkit-animation-duration: 4.3s;
              animation-duration: 4.3s;
    }
    .ball > :nth-child(2)::before {
      background-color: #9966ff;
    }
    .ball > :nth-child(3) {
      -webkit-animation-delay: -4.55s;
              animation-delay: -4.55s;
      -webkit-animation-duration: 5.1s;
              animation-duration: 5.1s;
    }
    .ball > :nth-child(3)::before {
      background-color: #aa80ff;
    }
    .ball > :nth-child(4) {
      -webkit-animation-delay: -2.0625s;
              animation-delay: -2.0625s;
      -webkit-animation-duration: 4.15s;
              animation-duration: 4.15s;
    }
    .ball > :nth-child(4)::before {
      background-color: #9661ff;
    }
    .ball > :nth-child(5) {
      -webkit-animation-delay: -1.725s;
              animation-delay: -1.725s;
      -webkit-animation-duration: 5.2s;
              animation-duration: 5.2s;
    }
    .ball > :nth-child(5)::before {
      background-color: #c2a3ff;
    }
    .ball > :nth-child(6) {
      -webkit-animation-delay: -2.4125s;
              animation-delay: -2.4125s;
      -webkit-animation-duration: 4.65s;
              animation-duration: 4.65s;
    }
    .ball > :nth-child(6)::before {
      background-color: #8b52ff;
    }
    .ball > :nth-child(7) {
      -webkit-animation-delay: -4.8s;
              animation-delay: -4.8s;
      -webkit-animation-duration: 6.2s;
              animation-duration: 6.2s;
    }
    .ball > :nth-child(7)::before {
      background-color: #d6c2ff;
    }
    .ball > :nth-child(8) {
      -webkit-animation-delay: -0.9875s;
              animation-delay: -0.9875s;
      -webkit-animation-duration: 5.3s;
              animation-duration: 5.3s;
    }
    .ball > :nth-child(8)::before {
      background-color: #cfb8ff;
    }
    .ball > :nth-child(9) {
      -webkit-animation-delay: -4.6125s;
              animation-delay: -4.6125s;
      -webkit-animation-duration: 4.25s;
              animation-duration: 4.25s;
    }
    .ball > :nth-child(9)::before {
      background-color: #d3bdff;
    }
    .ball > :nth-child(10) {
      -webkit-animation-delay: -4.0375s;
              animation-delay: -4.0375s;
      -webkit-animation-duration: 4.05s;
              animation-duration: 4.05s;
    }
    .ball > :nth-child(10)::before {
      background-color: #9c6bff;
    }
    .ball > :nth-child(11) {
      -webkit-animation-delay: -4.2s;
              animation-delay: -4.2s;
      -webkit-animation-duration: 5.95s;
              animation-duration: 5.95s;
    }
    .ball > :nth-child(11)::before {
      background-color: #8f57ff;
    }
    .ball > :nth-child(12) {
      -webkit-animation-delay: -1.35s;
              animation-delay: -1.35s;
      -webkit-animation-duration: 4.35s;
              animation-duration: 4.35s;
    }
    .ball > :nth-child(12)::before {
      background-color: #ccb3ff;
    }
    .ball > :nth-child(13) {
      -webkit-animation-delay: -0.1125s;
              animation-delay: -0.1125s;
      -webkit-animation-duration: 4.15s;
              animation-duration: 4.15s;
    }
    .ball > :nth-child(13)::before {
      background-color: #742eff;
    }
    .ball > :nth-child(14) {
      -webkit-animation-delay: -0.9s;
              animation-delay: -0.9s;
      -webkit-animation-duration: 4.05s;
              animation-duration: 4.05s;
    }
    .ball > :nth-child(14)::before {
      background-color: #b18aff;
    }
    .ball > :nth-child(15) {
      -webkit-animation-delay: -3.1375s;
              animation-delay: -3.1375s;
      -webkit-animation-duration: 4.15s;
              animation-duration: 4.15s;
    }
    .ball > :nth-child(15)::before {
      background-color: #be9eff;
    }
    .ball > :nth-child(16) {
      -webkit-animation-delay: -1.3375s;
              animation-delay: -1.3375s;
      -webkit-animation-duration: 6.05s;
              animation-duration: 6.05s;
    }
    .ball > :nth-child(16)::before {
      background-color: #7733ff;
    }
    .ball > :nth-child(17) {
      -webkit-animation-delay: -2.2875s;
              animation-delay: -2.2875s;
      -webkit-animation-duration: 6.1s;
              animation-duration: 6.1s;
    }
    .ball > :nth-child(17)::before {
      background-color: #c5a8ff;
    }
    .ball > :nth-child(18) {
      -webkit-animation-delay: -2.075s;
              animation-delay: -2.075s;
      -webkit-animation-duration: 4.35s;
              animation-duration: 4.35s;
    }
    .ball > :nth-child(18)::before {
      background-color: #9661ff;
    }
    .ball > :nth-child(19) {
      -webkit-animation-delay: -4.25s;
              animation-delay: -4.25s;
      -webkit-animation-duration: 5.4s;
              animation-duration: 5.4s;
    }
    .ball > :nth-child(19)::before {
      background-color: #aa80ff;
    }
    .ball > :nth-child(20) {
      -webkit-animation-delay: -2.4875s;
              animation-delay: -2.4875s;
      -webkit-animation-duration: 4.35s;
              animation-duration: 4.35s;
    }
    .ball > :nth-child(20)::before {
      background-color: #b48fff;
    }
    .ball > :nth-child(21) {
      -webkit-animation-delay: -0.2625s;
              animation-delay: -0.2625s;
      -webkit-animation-duration: 4.7s;
              animation-duration: 4.7s;
    }
    .ball > :nth-child(21)::before {
      background-color: #b18aff;
    }
    .ball > :nth-child(22) {
      -webkit-animation-delay: -3.7125s;
              animation-delay: -3.7125s;
      -webkit-animation-duration: 5.1s;
              animation-duration: 5.1s;
    }
    .ball > :nth-child(22)::before {
      background-color: #c9adff;
    }
    .ball > :nth-child(23) {
      -webkit-animation-delay: -4.5875s;
              animation-delay: -4.5875s;
      -webkit-animation-duration: 4.65s;
              animation-duration: 4.65s;
    }
    .ball > :nth-child(23)::before {
      background-color: #884dff;
    }
    .ball > :nth-child(24) {
      -webkit-animation-delay: -1.3125s;
              animation-delay: -1.3125s;
      -webkit-animation-duration: 4.9s;
              animation-duration: 4.9s;
    }
    .ball > :nth-child(24)::before {
      background-color: #9c6bff;
    }
    .ball > :nth-child(25) {
      -webkit-animation-delay: -4.35s;
              animation-delay: -4.35s;
      -webkit-animation-duration: 4.9s;
              animation-duration: 4.9s;
    }
    .ball > :nth-child(25)::before {
      background-color: #ad85ff;
    }
    .ball > :nth-child(26) {
      -webkit-animation-delay: -1.3125s;
              animation-delay: -1.3125s;
      -webkit-animation-duration: 4.2s;
              animation-duration: 4.2s;
    }
    .ball > :nth-child(26)::before {
      background-color: #bb99ff;
    }
    .ball > :nth-child(27) {
      -webkit-animation-delay: -3.325s;
              animation-delay: -3.325s;
      -webkit-animation-duration: 5.2s;
              animation-duration: 5.2s;
    }
    .ball > :nth-child(27)::before {
      background-color: #7a38ff;
    }
    .ball > :nth-child(28) {
      -webkit-animation-delay: -1.425s;
              animation-delay: -1.425s;
      -webkit-animation-duration: 4.3s;
              animation-duration: 4.3s;
    }
    .ball > :nth-child(28)::before {
      background-color: #a070ff;
    }
    .ball > :nth-child(29) {
      -webkit-animation-delay: -2.5875s;
              animation-delay: -2.5875s;
      -webkit-animation-duration: 3.95s;
              animation-duration: 3.95s;
    }
    .ball > :nth-child(29)::before {
      background-color: #c2a3ff;
    }
    .ball > :nth-child(30) {
      -webkit-animation-delay: -0.175s;
              animation-delay: -0.175s;
      -webkit-animation-duration: 5.85s;
              animation-duration: 5.85s;
    }
    .ball > :nth-child(30)::before {
      background-color: #be9eff;
    }
    .ball > :nth-child(31) {
      -webkit-animation-delay: -2.3s;
              animation-delay: -2.3s;
      -webkit-animation-duration: 6s;
              animation-duration: 6s;
    }
    .ball > :nth-child(31)::before {
      background-color: #bb99ff;
    }
    .ball > :nth-child(32) {
      -webkit-animation-delay: -4.5625s;
              animation-delay: -4.5625s;
      -webkit-animation-duration: 5.75s;
              animation-duration: 5.75s;
    }
    .ball > :nth-child(32)::before {
      background-color: #7029ff;
    }
    .ball > :nth-child(33) {
      -webkit-animation-delay: -0.7625s;
              animation-delay: -0.7625s;
      -webkit-animation-duration: 5.3s;
              animation-duration: 5.3s;
    }
    .ball > :nth-child(33)::before {
      background-color: #cfb8ff;
    }
    .ball > :nth-child(34) {
      -webkit-animation-delay: -4.9125s;
              animation-delay: -4.9125s;
      -webkit-animation-duration: 4.95s;
              animation-duration: 4.95s;
    }
    .ball > :nth-child(34)::before {
      background-color: #925cff;
    }
    .ball > :nth-child(35) {
      -webkit-animation-delay: -2s;
              animation-delay: -2s;
      -webkit-animation-duration: 4.9s;
              animation-duration: 4.9s;
    }
    .ball > :nth-child(35)::before {
      background-color: #be9eff;
    }
    .ball > :nth-child(36) {
      -webkit-animation-delay: -3.9125s;
              animation-delay: -3.9125s;
      -webkit-animation-duration: 4.8s;
              animation-duration: 4.8s;
    }
    .ball > :nth-child(36)::before {
      background-color: #7e3dff;
    }
    .ball > :nth-child(37) {
      -webkit-animation-delay: -2.4s;
              animation-delay: -2.4s;
      -webkit-animation-duration: 5.05s;
              animation-duration: 5.05s;
    }
    .ball > :nth-child(37)::before {
      background-color: #884dff;
    }
    .ball > :nth-child(38) {
      -webkit-animation-delay: -1.3625s;
              animation-delay: -1.3625s;
      -webkit-animation-duration: 5.05s;
              animation-duration: 5.05s;
    }
    .ball > :nth-child(38)::before {
      background-color: #be9eff;
    }
    .ball > :nth-child(39) {
      -webkit-animation-delay: -1.25s;
              animation-delay: -1.25s;
      -webkit-animation-duration: 5.05s;
              animation-duration: 5.05s;
    }
    .ball > :nth-child(39)::before {
      background-color: #6d24ff;
    }
    .ball > :nth-child(40) {
      -webkit-animation-delay: -4.7s;
              animation-delay: -4.7s;
      -webkit-animation-duration: 5.65s;
              animation-duration: 5.65s;
    }
    .ball > :nth-child(40)::before {
      background-color: #8142ff;
    }
    .ball > :nth-child(41) {
      -webkit-animation-delay: -2.6125s;
              animation-delay: -2.6125s;
      -webkit-animation-duration: 6.05s;
              animation-duration: 6.05s;
    }
    .ball > :nth-child(41)::before {
      background-color: #c2a3ff;
    }
    .ball > :nth-child(42) {
      -webkit-animation-delay: -4s;
              animation-delay: -4s;
      -webkit-animation-duration: 6.1s;
              animation-duration: 6.1s;
    }
    .ball > :nth-child(42)::before {
      background-color: #742eff;
    }
    .ball > :nth-child(43) {
      -webkit-animation-delay: -3.825s;
              animation-delay: -3.825s;
      -webkit-animation-duration: 5.8s;
              animation-duration: 5.8s;
    }
    .ball > :nth-child(43)::before {
      background-color: #cfb8ff;
    }
    .ball > :nth-child(44) {
      -webkit-animation-delay: -1.3375s;
              animation-delay: -1.3375s;
      -webkit-animation-duration: 5.3s;
              animation-duration: 5.3s;
    }
    .ball > :nth-child(44)::before {
      background-color: #d3bdff;
    }
    .ball > :nth-child(45) {
      -webkit-a.........完整代码请登录后点击上方下载按钮下载查看

网友评论0