当前位置: 首页 > java >正文

CSS 3D动画,围绕旋转动画Demo

效果:

鼠标移入停止旋转移出继续旋转,这种效果有一个问题就是中心的图片层级较高,四周的小图片层级较低,小图片旋转至前面时会被中心的图片覆盖,所以鼠标移入移出时可能会选不中图片,会导致无法停止、继续播放动画需要注意!可以通过调整位置,错位的方式解决或者调整z-index属性层级显示。

<div class="content"><div class="skin_action"><div class="centerIcon"></div><div class="planet"><div class="ball ball1"></div><div class="ball ball2"></div><div class="ball ball3"></div><div class="ball ball4"></div></div></div>
</div>

CSS:

.skin_action{width: 50%;height: 87%;position: relative;left: 10%;top: 5%;
}
.centerIcon{width: 60%;height: 50%;background-image: url('/img/newLogin-centerIcon.png');background-size: 100% 100%;background-repeat: no-repeat;background-position: center;position: relative;z-index: 1;left: 20%;top: 13%;
}
.skin_action .planet {/*border: 2px solid #fff;*/width: 90%;height: 100%;transform-style: preserve-3d;animation: planet-rotate 30s linear infinite;position: relative;z-index: 0;top: -57%;left: 5%;
}
.skin_action .ball1 {width: 25%;height: 30%;left: 0%;top: 0%;cursor: pointer;position: absolute;background-image: url("/img/newLogin-ydhlIcon.png");background-size: 100% 100%;background-repeat: no-repeat;background-position: center;animation: ball1-rotate 30s linear infinite;
}
.skin_action .ball2 {width: 25%;height: 30%;left: 80%;top: 0%;cursor: pointer;position: absolute;background-image: url("/img/newLogin-xtszIcon.png");background-size: 100% 100%;background-repeat: no-repeat;background-position: center;animation: ball1-rotate 30s linear infinite;
}
.skin_action .ball3 {width: 25%;height: 30%;left: 0%;top: 80%;cursor: pointer;position: absolute;background-image: url("/img/newLogin-sbjkIcon.png");background-size: 100% 100%;background-repeat: no-repeat;background-position: center;animation: ball1-rotate 30s linear infinite;
}
.skin_action .ball4 {width: 25%;height: 30%;left: 80%;top: 70%;cursor: pointer;position: absolute;background-image: url("/img/newLogin-ztjcIcon.png");background-size: 100% 100%;background-repeat: no-repeat;background-position: center;animation: ball1-rotate 30s linear infinite;
}@keyframes planet-rotate {0% {transform: rotate(0deg) scaleY(0.5) rotate(0);}100% {transform: rotate(0deg) scaleY(0.5) rotate(360deg);}
}
@keyframes ball1-rotate {0% {transform: rotate(0) scaleY(2) rotate(0deg);}100% {transform: rotate(-360deg) scaleY(2) rotate(0deg);}}

JS:

    /*鼠标移入时暂停动画*/$(document).ready(function() {var $planet = $('.planet');var $boxes = $('.ball');// 鼠标移入时暂停动画$('.planet .ball,.planet').on('mouseenter', function() {$planet.css('animation-play-state', 'paused');$boxes.css('animation-play-state', 'paused');});// 鼠标移出时恢复动画$('.planet .ball,.planet').on('mouseleave', function() {$planet.css('animation-play-state', 'running');$boxes.css('animation-play-state', 'running');});});

http://www.xdnf.cn/news/18413.html

相关文章:

  • 面试可能问到的问题思考-Redis
  • 机器学习7
  • 网络与信息安全有哪些岗位:(5)安全开发工程师
  • Ubuntu22.04配置网络上网
  • Ubuntu Server 安装 gvm 管理 Go 语言开发环境
  • 自然语言处理NLP L4: 高级语言模型——四种泛化平滑方式
  • 【TrOCR】用Transformer和torch库实现TrOCR模型
  • Matplotlib+HTML+JS:打造可交互的动态数据仪表盘
  • 智慧工厂的 “隐形大脑”:边缘计算网关凭什么重构设备连接新逻辑?
  • 详细说明http协议特别是conten-length和chunk编码,并且用linux的命令行演示整个过程
  • Go语言变量声明与初始化详解
  • 一个状态机如何启动/停止另一个状态机
  • 【机器学习 / 深度学习】基础教程
  • StarRocks不能启动 ,StarRocksFe节点不能启动问题 处理
  • 生信分析自学攻略 | R语言函数与参数介绍
  • Notepad++换行符替换
  • 造成云手机闪退的原因有哪些?
  • HarmonyOS 实战:6 种实现实时数据更新的方案全解析(含完整 Demo)
  • java18学习笔记-Simple Web Server
  • 【LeetCode 415】—字符串相加算法详解
  • 【数据可视化-96】使用 Pyecharts 绘制主题河流图(ThemeRiver):步骤与数据组织形式
  • 深度学习-168-MCP技术之VSCode中安装插件Cline客户端应用MCP Server工具
  • 计算机网络-1——第一阶段
  • 在.NET 8 中使用中介模式优雅处理多版本 API 请求
  • 【51单片机】【protues仿真】基于51单片机16键电子琴系统
  • 高可用操作步骤
  • 纷玩岛协议抢票免费源码
  • Spring两个核心IoCDI(一)
  • java基础(十三)消息队列
  • #千问海报大赛