您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

一文讲解css3实现椭圆轨迹旋转(总结)

2024/6/30 3:33:23发布31次查看
之前的文章《手把手教你使用vue2代码改成vue3(图文详解)》中,给大家介绍了怎么使用vue2代码改成vue3。下面本篇文章给大家了解css3实现椭圆轨迹旋转,小伙伴们收藏好哦~
css3实现椭圆轨迹旋转
最近需要实现如下效果
最开始用css3d旋转写,只能实现如下效果
没办法把所有的圆转向正面,不知道是我的操作不对,还是3d旋转无法实现,有知道的大佬还请赐教啊
没法用3d实现只能转向2d了,只要实现按椭圆旋转就ok了
1、x轴y轴在一个矩形内移动
路径为斜线
.ball { 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;}}
2、设置动画延迟
设置y轴动画延迟为动画时长的一半(延迟设为负数动画开始不会有延迟空白,感兴趣的同学可以试试正数延迟),可以看到运动轨迹变成菱形了,有点感觉了
.ball { animation: animx 2s linear 0s infinite alternate, animy 2s linear -1s infinite alternate }
3、设置三次贝塞尔曲线
.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 }
4、缩小放大
为了看起来有立体感添加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) } }
大功告成!
完整效果地址:https://codepen.io/yaowei9363/pen/pyxvne?editors=1100
推荐学习:css3视频教程
以上就是一文讲解css3实现椭圆轨迹旋转(总结)的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product