美文网首页
css实现椭圆轨迹旋转

css实现椭圆轨迹旋转

作者: Enginner_XZ | 来源:发表于2020-12-09 17:23 被阅读0次
    image.png

    X轴Y轴在一个矩形内移动

    做斜线运动

    .ball {
        position: absolute;
        animation:
          animX 2s linear  infinite alternate,
          animY 2s linear  infinite alternate
      }
    @keyframes animX{
          0% {left: 0px;}
        100% {left: 500px;}
    }
    @keyframes animY{
          0% {top: 0px;}
        100% {top: 300px;}
    }
    
    image.png

    设置动画延时

    设置Y轴延时为动画时长的一半, 运动轨迹变成菱形

     .ball {
         animation: 
           animX 2s linear 0s infinite alternate,
           animY 2s linear -1s infinite alternate
       }
    
    image.png

    设置三次贝塞尔曲线

      .ball {
         animation: 
           animX 2s  cubic-bezier(0.36, 0, 0.64, 1) -1s infinite alternate,
           animY 2s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate
     }
    

    缩小放大

    为了看起来有立体感添加scale属性,scale动画应该是X轴和Y轴的时间总和

    .ball1 {
        animation:
          animX 2s  cubic-bezier(0.36, 0, 0.64, 1) -1s infinite alternate,
          animY 2s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate,
          scale 4s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate;
      }
     @keyframes scale {
    
        0% {
          transform: scale(0.7)
        }
        50% {
          transform: scale(1)
        }
        100% {
          transform: scale(0.7)
       }
     }
    
    image.png
    转载自 https://www.cnblogs.com/---godzilla---/p/11441222.html

    相关文章

      网友评论

          本文标题:css实现椭圆轨迹旋转

          本文链接:https://www.haomeiwen.com/subject/qfohgktx.html