一、CSS3 transform变换
1、translate(x,y) 设置盒子位移
2、scale(x,y) 设置盒子缩放
3、rotate(deg) 设置盒子旋转
4、skew(x-angle,y-angle) 设置盒子斜切
5、perspective 设置透视距离
6、transform-style flat | preserve-3d 设置盒子是否按3d空间显示
7、translateX、translateY、translateZ 设置三维移动
8、rotateX、rotateY、rotateZ 设置三维旋转
9、scaleX、scaleY、scaleZ 设置三维缩放
10、tranform-origin 设置变形的中心点
11、backface-visibility 设置盒子背面是否可见
二、CSS3 animation动画
1、@keyframes 定义关键帧动画
2、animation-name 动画名称
3、animation-duration 动画时间
4、animation-timing-function 动画曲线
linear 匀速
ease 开始和结束慢速
ease-in 开始是慢速
ease-out 结束时慢速
ease-in-out 开始和结束时慢速
steps 动画步数
5、animation-delay 动画延迟
6、animation-iteration-count 动画播放次数 n|infinite
7、animation-direction
normal 默认动画结束不返回
Alternate 动画结束后返回
8、animation-play-state 动画状态
paused 停止
running 运动
9、animation-fill-mode 动画前后的状态
none 不改变默认行为
forwards 当动画完成后,保持最后一个属性值(在最后一个关键帧中定义)
backwards 在 animation-delay 所指定的一段时间内,在动画显示之前,应用开始属性值(在第一个关键帧中定义)
both 向前和向后填充模式都被应用
10、animation:name duration timing-function delay iteration-count direction;同时设置多个属性
这里我用animation动画写了一个加载是的动画。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>loading。。。</title>
<style type="text/css">
.clearfix:before,.clear:after{
content: "";
display: table;
clear: both;
}
.box{
width: 450px;
height: 200px;
margin: 100px auto 0px;
border: 1px solid #000;
}
.colorBox{
height: 170px;
}
.smallBox{
width: 30px;
height: 50px;
margin: 60px 30px;
border-radius: 10px;
float: left;
}
.smallBoxColor1{
background: gold;
animation: scale 0.5s ease-out infinite alternate both;
}/*
scale是下面定义的一个函数
0.5s是这个动作执行一次的时间
ease-out是过渡的方式
infinite是指这个动作重复无限次/想要执行几次就写几
alternate 使方块不会突然变大或变小
*/
.smallBoxColor2{
background: blue;
animation: scale 0.5s ease-out 0.1s infinite alternate both;
}
.smallBoxColor3{
background: red;
animation: scale 0.5s ease-out 0.2s infinite alternate both;
}
.smallBoxColor4{
background: greenyellow;
animation: scale 0.5s ease-out 0.3s infinite alternate both;
}
.smallBoxColor5{
background: pink;
animation: scale 0.5s ease-out 0.4s infinite alternate both;
}
.fontBox{
height: 30px;
}
.fontBox p{
text-align: center;
font: 20px "微软雅黑";
color: #000;
margin: 0px;
}
@keyframes scale{
from{
transform: scaleY(0.5);
}
to{
transform: scaleY(1.5);
}
}
</style>
</head>
<body>
<div class="box">
<div class="colorBox clearfix">
<div class="smallBox smallBoxColor1"></div>
<div class="smallBox smallBoxColor2"></div>
<div class="smallBox smallBoxColor3"></div>
<div class="smallBox smallBoxColor4"></div>
<div class="smallBox smallBoxColor5"></div>
</div>
<div class="fontBox">
<p>loading...</p>
</div>
</div>
</body>
</html>