头闻号

上海畅胜化工有限公司

钛白粉|硫酸钡|碳酸钙|羧酸|高岭土|石油蜡

首页 > 新闻中心 > 科技常识:HTML复杂动画和变形
科技常识:HTML复杂动画和变形
发布时间:2023-02-01 10:46:49        浏览次数:1        返回列表

今天小编跟大家讲解下有关HTML复杂动画和变形 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了有关HTML复杂动画和变形 的相关资料,希望小伙伴们看了有所帮助。

1、复杂动画

(1)涉及到的属性:

animation-name:动画名称;

animation-duration:单次动画总时长;

animation-timing-function:时间函数;

animation-delay:播放前延时的时长;

animation-iteration-count:播放次数(具体的数字),当设置infinite时是循环播放;

animation-direction:播放顺序,其中normal是正常播放,alternate是轮流反向播放,播放次数必须在2次以上。

(2)书写方式

@keyframes 名字(自己取一个名字){ ——>定义一个动画}

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport"content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible"content="ie=edge"> <title>复杂动画练习</title></head><style> .box { width: 200px; height: 200px; background-color: blueviolet; border: solid black; position: relative; top: 0; animation-name: demo; animation-duration: 5s; animation-timing-function: cubic-bezier(0.075, 0.82, 0.165, 1); animation-delay: 3s; animation-iteration-count: infinite; animation-direction: alternate; } @keyframes demo { from { top: 0; border-radius: 0; } 20% { top: 100px; left: 100px; border-radius: 30px; } 50% { top: 200px; left: 100px; border-radius: 30px } to { top: 400px; left: 400px; border-radius: 50% } }</style><body> <div class="box"> 动画练习 <!-- <img src="http://www.aidi.net.cn/article/detial/5703/img/2010011712541759.jpg"alt=""> --> </div></body></html>

效果如下:

2、盒子变形

(1) 变形:通过变形可以改变盒子的视觉效果,变形不会改变盒子原本的位置和尺寸,因此不会对其他元素造成影响。

(2) 变形的类型

Translate(移动)

Scale(缩放,1以下是缩小,1以上是扩大)

Skew(倾斜,单位deg)

Rotate(旋转,默认是沿着Z轴旋转,单位deg)

(3) 定义原点

Transform-origin:设置盒子的中心点。

(4) 其他属性

背面可见性:backface-visibility

visible:默认值,背面可见

hidden:背面不可见

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport"content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible"content="ie=edge"> <title>盒子变形</title></head><style> .box { width: 260px; height: 260px; position: relative; } .zheng, .fan { width: 260px; height: 260px; font-size: 26px; border: solid black; color: white; text-align: center; line-height: 260px; position: absolute; top: 0; left: 0; transition: all 1s; backface-visibility: hidden; } .zheng { background-color: blueviolet; z-index: 2; } .fan { background-color: green; transform: rotateY(-180deg) rotateZ(-180deg); } .box:hover .zheng { transform: rotateY(180deg) rotateZ(180deg); } .box:hover .fan { transform: rotateY(0deg) rotateZ(0deg); }</style><body> <div class="box"> <div class="zheng">正面</div> <div class="fan">反面</div> </div></body></html>

变形效果如下:

原文:https://www.cnblogs.com/czy18227988114/archive/2019/10/07/11629634.html

来源:爱蒂网