今天小编跟大家讲解下有关css3实现椭圆轨迹旋转 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了有关css3实现椭圆轨迹旋转 的相关资料,希望小伙伴们看了有所帮助。
实现效果
X轴Y轴在一个矩形内移动做斜线运动
.ball { position: absolute; animation: animX 2s linear infinite alternate, animY 2s linear infinite alternate [email protected] animX{ 0% {left: 0px;} 100% {left: 500px;[email protected] animY{ 0% {top: 0px;} 100% {top: 300px;}}设置动画延时设置Y轴延时为动画时长的一半, 运动轨迹变成菱形
.ball { animation: animX 2s linear 0s infinite alternate, animY 2s linear -1s infinite alternate}设置三次贝塞尔曲线.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) } }来源:爱蒂网