具有关键帧和变换的 CSS3 动画

标签 css css-animations keyframe

我想对 CSS 动画做一个类似的 Action :

http://truthlabs.com/

我在处理关键帧的地方创建了一个文件,但效果不佳。

我希望圆圈能够从中心的固定点开始绕轴转一整圈。

谢谢。

HTML 文件:

    <ul>
        <li style="animation: move1 2s infinite;"></li>
        <li style="animation: move2 2s infinite;"></li>
        <li style="animation: move3 2s infinite;"></li>
        <li style="animation: move4 2s infinite;"></li>
        <li style="animation: move5 2s infinite;"></li>
        <li style="animation: move6 2s infinite;"></li>
        <li style="animation: move7 2s infinite;"></li>
        <li style="animation: move8 2s infinite;"></li>
        <li style="animation: move9 2s infinite;"></li>
        <li style="animation: move10 2s infinite;"></li>
    </ul>

</body>

CSS 文件:

        body, html {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }

    ul{
        display: block;
        width: 1920px;
        height: 1080px;
        margin: 0;
        padding: 0;
    }

    li {
        position: absolute;
        display: block;
        top: 50%;
        left: 50%;
        /*transform: translate(-50%, -50%);*/
        border: 1px solid #000;
        border-radius: 100%;
        list-style: none;
    }

    @keyframes move1 {
      0% {
        transform: translate(-46%, -50%);
        width:400px; height:400px; 
      }
      50% {
        transform: translate(-54%, -50%);
        width:400px; height:400px; 
      }
      100% {
        transform: translate(-46%, -50%);
        width:400px; height:400px; 
      }
    }

    @keyframes move2 {
      0% {
        transform: translate(-50%, -46%);
        width:405px; height:405px; 
      }
      50% {
        transform: translate(-50%, -54%);
        width:405px; height:405px; 
      }
      100% {
        transform: translate(-50%, -46%);
        width:405px; height:405px; 
      }
    }

    @keyframes move3 {
      0% {
        transform: translate(-47%, -50%);
        width:410px; height:410px; 
      }
      50% {
        transform: translate(-55%, -50%);
        width:410px; height:410px; 
      }
      100% {
        transform: translate(-47%, -50%);
        width:410px; height:410px; 
      }
    }

    @keyframes move4 {
      0% {
        transform: translate(-50%, -48%);
        width:415px; height:415px; 
      }
      50% {
        transform: translate(-50%, -56%);
        width:415px; height:415px; 
      }
      100% {
        transform: translate(-50%, -48%);
        width:415px; height:415px; 
      }
    }

    @keyframes move5 {
      0% {
        transform: translate(-49%, -50%);
        width:420px; height:420px; 
      }
      50% {
        transform: translate(-57%, -50%);
        width:420px; height:420px; 
      }
      100% {
        transform: translate(-49%, -50%);
        width:420px; height:420px; 
      }
    }

    @keyframes move6 {
      0% {
        transform: translate(-50%, -50%);
        width:425px; height:425px; 
      }
      50% {
        transform: translate(-50%, -58%);
        width:425px; height:425px; 
      }
      100% {
        transform: translate(-50%, -50%);
        width:425px; height:425px; 
      }
    }

    @keyframes move7 {
      0% {
        transform: translate(-51%, -50%);
        width:430px; height:430px; 
      }
      50% {
        transform: translate(-59%, -50%);
        width:430px; height:430px; 
      }
      100% {
        transform: translate(-51%, -50%);
        width:430px; height:430px; 
      }
    }

    @keyframes move8 {
      0% {
        transform: translate(-50%, -52%);
        width:435px; height:435px; 
      }
      50% {
        transform: translate(-50%, -60%);
        width:435px; height:435px; 
      }
      100% {
        transform: translate(-50%, -52%);
        width:435px; height:435px; 
      }
    }

    @keyframes move9 {
      0% {
        transform: translate(-53%, -50%);
        width:440px; height:440px; 
      }
      50% {
        transform: translate(-61%, -50%);
        width:440px; height:440px; 
      }
      100% {
        transform: translate(-53%, -50%);
        width:440px; height:440px; 
      }
    }

    @keyframes move10 {
      0% {
        transform: translate(-50%, -54%);
        width:445px; height:445px; 
      }
      50% {
        transform: translate(-50%, -62%);
        width:445px; height:445px; 
      }
      100% {
        transform: translate(-50%, -54%);
        width:445px; height:445px; 
      }
    }

演示:http://plnkr.co/edit/Ntqtszay7BOg4pz8zCv4?p=preview

最佳答案

这是你想要的吗? https://jsfiddle.net/DIRTY_SMITH/kn7qjg6c/5/

 @keyframes move1 {
      0% {
        transform: translate(-46%, -50%);
        width:400px; height:400px; 
      }
      50% {
        transform: translate(-54%, -50%);
        width:400px; height:400px; 
      }
      100% {
        transform: translate(-46%, -50%);
        width:400px; height:400px; 
      }
    }

    @keyframes move2 {
      0% {
        transform: translate(-50%, -46%);
        width:1000px; height:1000px; 
      }
      50% {
        transform: translate(-50%, -54%);
        width:405px; height:405px; 
      }
      100% {
        transform: translate(-50%, -46%);
        width:405px; height:405px; 
      }
    }

关于具有关键帧和变换的 CSS3 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32099585/

相关文章:

javascript - 使用 jQuery Animate 进行页面转换,同时修复封面图像

javascript - 为什么 window.onscroll 滞后于实际滚动?

javascript - 当宽度为 100% 时,低分辨率图像显得模糊

javascript - CSS 动画最终关键帧中的视口(viewport)单位不会在 Safari 中重新计算

css - 在 nth-child/CSS3 结束时停止动画

css - IE9 显示不正确,我的 html 标题是否正确?

css - ng-animate 在 iOS 上导致闪烁

html - 使用表格单元格内的关键帧创建 ‘typed’ 效果

javascript - 从关键帧获取模糊滤镜值

wpf - 在确切的关键帧停止 Storyboard