search

Home  >  Q&A  >  body text

CSS3动画,让元素沿圆弧移动

CSS3动画,让绝对定位的元素沿圆弧移动,

@keyframes bimg1 {
      0% {top: 10%;left: 12%;width:50%;}
      30% {top: -10%;left: -12%;width:45%;}
      100% {top: 19%;left: 52%;width:40%;}
    }
    

这样写的话,会是线性的移动,从一个点,移动到另外一个点,想要的效果是按圆弧来移动

天蓬老师天蓬老师2782 days ago732

reply all(4)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 11:23:47

    The x-axis and y-axis animations are written separately, and then the two speeds are different, which will form a curved motion. The specific curve can be calculated, just write a
    or you can directly give the x and y values ​​​​of the corresponding key frames

    @keyframes bimg1 {
          0% {top: 0;}
          100% {top: 200px;}
    }
    @keyframes bimg2 {
      0%  {left: 0;}
      100% {left: 200px;}
    }
     #item {
      animation: bimg1 2s infinite cubic-bezier(0,0,1,1),bimg2 2s infinite cubic-bezier(0,1,0,1);
      width: 10px;
      height: 10px;
      position: absolute;
      background: red;
    }

    reply
    0
  • PHPz

    PHPz2017-04-17 11:23:47

    用transform: rotate()

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 11:23:47

    cc http://segmentfault.com/q/1010000002951253/a-1020000002951387

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 11:23:47

    http://codepen.io/zzuieliyaoli/pen/EVVGKM

    The key is:

    transform-origin、transform: rotate();

    reply
    0
  • Cancelreply