× 目录 [1]漂浮的白云 [2]旋转的星球 [3]正方体合成
前面的话
前面介绍过动画animation的详细用法,本文主要介绍动画animation的三个效果
漂浮的白云
【效果演示】
【简要介绍】
漂浮的白云主要通过远景白云和近景白云来实现立体漂浮效果。远景和近景分别使用两张背景图片,通过改变其背景定位来实现白云移动效果,通过设置不同的动画持续时间来实现交错漂浮的效果
【主要代码】
.box{ position: relative; height: 300px; width: 500px;} .in1,.in2{ position: absolute; height: 100%; width: 100%; background-size:cover; animation: move 100s infinite linear alternate;}@keyframes move{ 100%{background-position: 500% 0;}}.in1{ background-image: url('http://sandbox.runjs.cn/uploads/rs/26/ddzmgynp/cloud.png'); }.in2{ background-image: url('http://sandbox.runjs.cn/uploads/rs/26/ddzmgynp/cloud1.png'); animation-duration: 10s;}
<div class="box"> <div class="in1"></div> <div class="in2"></div></div>
源码查看
旋转的星球
【效果演示】
【简要介绍】
旋转的星球主要通过rotate()旋转函数来实现。实际上,蓝色的地球和黑色的月球并没有发生旋转,只是其父级旋转形成的视觉上的旋转效果
【代码演示】
.box{ transform: scale(0.5); position: relative; padding: 1px; height: 300px; width: 300px;} .sunline{ position:relative; height: 400px; width: 400px; border: 2px solid black; border-radius: 50%; margin: 50px 0 0 50px; display: flex; animation: rotate 10s infinite linear;}.sun{ height: 100px; width: 100px; margin: auto; background-color: red; border-radius: 50%; box-shadow: 5px 5px 10px red,-5px -5px 10px red,5px -5px 10px red,-5px 5px 10px red;}.earthline{ position: absolute; right: 0; top: 50%; height: 200px; width: 200px; margin: -100px -100px 0 0; border: 1px solid black; border-radius: 50%; display: flex; animation: rotate 2s infinite linear;}.earth{ margin: auto; height: 50px; width: 50px; background-color: blue; border-radius: 50%;}.moon{ position: absolute; left: 0; top: 50%; height: 20px; width: 20px; margin: -10px 0 0 -10px; background-color: black; border-radius: 50%;}@keyframes rotate{ 100%{transform:rotate(360deg);}}
<div class="box"> <div class="sunline"> <div class="sun"></div> <div class="earthline"> <div class="earth"></div> <div class="moon"></div> </div> </div></div>
源码查看
正方体合成
【效果演示】
【简要介绍】
该效果主要通过设置计算后的延迟时间来达到正方体的各个边顺序动画的效果。一次动画结束后,通过触发animationend事件重置animation-name来实现重复动画的效果
【代码演示】
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);}}
<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>
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);
源码查看

公众号网页更新缓存,这玩意儿,说简单也简单,说复杂也够你喝一壶的。你辛辛苦苦更新了公众号文章,结果用户打开还是老版本,这滋味,谁受得了?这篇文章,咱就来扒一扒这背后的弯弯绕绕,以及如何优雅地解决这个问题。读完之后,你就能轻松应对各种缓存难题,让你的用户始终体验到最新鲜的内容。先说点基础的。网页缓存,说白了就是浏览器或者服务器为了提高访问速度,把一些静态资源(比如图片、CSS、JS)或者页面内容存储起来。下次访问时,直接从缓存里取,不用再重新下载,速度自然快。但这玩意儿,也是个双刃剑。新版本上线,

本文讨论了使用HTML5表单验证属性,例如必需的,图案,最小,最大和长度限制,以直接在浏览器中验证用户输入。

本文展示了使用CSS为网页中添加有效的PNG边框。 它认为,与JavaScript或库相比,CSS提供了出色的性能,详细介绍了如何调整边界宽度,样式和颜色以获得微妙或突出的效果

本文讨论了html&lt; datalist&gt;元素,通过提供自动完整建议,改善用户体验并减少错误来增强表格。Character计数:159

本文讨论了HTML&lt; Progress&gt;元素,其目的,样式和与&lt; meter&gt;元素。主要重点是使用&lt; progress&gt;为了完成任务和LT;仪表&gt;对于stati

本文解释了HTML5&lt; time&gt;语义日期/时间表示的元素。 它强调了DateTime属性对机器可读性(ISO 8601格式)的重要性,并在人类可读文本旁边,增强Accessibilit

本文讨论了HTML&lt; meter&gt;元素,用于在一个范围内显示标量或分数值及其在Web开发中的常见应用。它区分了&lt; meter&gt;从&lt; progress&gt;和前


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

SublimeText3 Linux新版
SublimeText3 Linux最新版

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

WebStorm Mac版
好用的JavaScript开发工具

SublimeText3 英文版
推荐:为Win版本,支持代码提示!