动作 transition
transition 是 css3 的一大亮点,他常用的大概有以下一些属性:
- transition-property —规定设置过渡效果的 CSS 属性的名称
- transition-duration —规定完成过渡效果需要多少秒或毫秒
- transition-timing-function —规定速度效果的速度曲线
- transition-delay —定义过渡效果何时开始
一般只是单个动作
.btn{background-color: red;transition-timing-function: ease;transition-property: opacity,background-color,background-radius;transition-delay: 0.2s;transition-duration: 1s;width: 100px;height: 50px;margin: 0 auto;}.btn:hover{opacity: 0.3;background-color: seagreen;border-radius: 5px;}
animation + @keyframes
实现更复杂的动画效果@keyframes中的百分比,代表时间尺度上的百分比 ,后面跟着的是此时间点的样式
animation-name: none; /* 动画名称 */animation-duration: 0; /* 耗时 */animation-timing-function: ease; /* 效果,默认缓入缓出 */animation-delay: 0; /* 延迟 */animation-iteration-count: 1; /* 循环次数 */animation-direction: normal; /* 正放 or 倒放 */
.blueball {...background-color: #0080ff; /* 蓝色 */position: relative;animation: forward 4s; /* 执行 forward 动画,耗时 4s */}/* 三个关键帧: 起点(蓝色),蓝变绿,终点(橙色) */@keyframes forward {0% {left: 0; }50% {left: 200px; background-color: #009a61;}100% {left: 400px; background-color: orange;}}
transform
CSS 元素默认的坐标系,原点在左上角;而 transform 变换的原点位于元素中心
matrix矩阵变换translate位移scale缩放rotate绕轴旋转skew[skju:] 倾斜perspective透视距离
