分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

css3动画(animation)效果3-正方体合成

发布时间:2023-09-06 01:44责任编辑:郭大石关键词:动画
<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>旋转的星球</title> ???<style type="text/css"> ???????ul{ ???????????margin: 0; ???????????padding: 0; ???????????list-style: none; ???????} ???????.box{ ???????????height: 100px; ???????????width: 100px; ???????????perspective: 500px; ???????????margin: 50px 0 0 50px; ???????} ???????.list{ ???????????position: relative; ???????????height: 100px; ???????????width: 100px; ???????????background-color: blue; ???????????transform-style: preserve-3d; ???????????transform-origin: 0 0 0; ???????????animation: rotate 1s ?10s 3 both linear; ???????} ???????.in{ ???????????position: absolute; ???????????height: 100px; ???????????width: 100px; ???????} ???????.list .in:nth-child(6){ ???????????background-color: pink; ???????????transform-origin: top; ???????????animation: in6 2s both; ???????} ???????.list .in:nth-child(5){ ???????????background-color: lightgreen; ???????????transform-origin: right; ???????????animation: in5 2s 2s both; ???????} ???????.list .in:nth-child(4){ ???????????background-color: lightblue; ???????????transform-origin: bottom; ???????????animation: in4 2s 4s both; ???????} ???????.list .in:nth-child(3){ ???????????background-color: lightcoral; ???????????transform-origin: left; ???????????animation: in3 2s 6s both; ???????} ???????.list .in:nth-child(2){ ???????????background-color: lightcyan; ???????????animation: in2 2s 8s both; ???????} ???????.list .in:nth-child(1){background-color: lightsalmon;} ???????.box:hover .list{animation-play-state: paused;} ???????.box:hover .in{animation-play-state: paused;} ???????@keyframes in6{100%{transform: rotateX(90deg);}} ???????@keyframes in5{100%{transform: rotateY(90deg);}} ???????@keyframes in4{100%{transform: rotateX(-90deg);}} ???????@keyframes in3{100%{transform: rotateY(-90deg);}} ???????@keyframes in2{100%{transform: translateZ(100px);}} ???????@keyframes rotate{100%{transform: rotate3d(1,1,1,360deg);}} ???</style></head><body><div class="box"> ???<ul class="list" id="list"> ???????<li class="in"></li> ???????<li class="in"></li> ???????<li class="in"></li> ???????<li class="in"></li> ???????<li class="in"></li> ???????<li class="in"></li> ???</ul></div><script type="text/javascript"> ???list.addEventListener(‘animationend‘,function(e){ ???????e = e || event; ???????var target = e.target || e.srcElement; ???????if(target.nodeName == ‘UL‘){ ???????????list.style.animationName = ‘none‘; ???????????var children = list.getElementsByTagName(‘li‘); ???????????for(var i = 0; i < children.length;i++){ ???????????????children[i].style.animationName = ‘none‘; ???????????} ???????????setTimeout(function(){ ???????????????list.style.animationName = ‘rotate‘; ???????????????var children = list.getElementsByTagName(‘li‘); ???????????????for(var i = 0; i < children.length;i++){ ???????????????????children[i].style.animationName = ‘in‘ + (i+1); ???????????????} ???????????},100); ???????} ???},false);</script><strong>【简要介绍】</strong><p>该效果主要通过设置计算后的延迟时间来达到正方体的各个边顺序动画的效果。一次动画结束后,通过触发animationend事件重置animation-name来实现重复动画的效果</p></body></html>

效果图:

原链接:https://www.cnblogs.com/xiaohuochai/p/5419236.html

css3动画(animation)效果3-正方体合成

原文地址:https://www.cnblogs.com/huanghuali/p/8489551.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved