CSS之变换和动画

280 阅读1分钟

CSS变换

translate

标题
2Dtranslate(x,y)
3Dtranslate3d(x,y,z) translateX(50px) translateY(50px) translateZ(50px

rotate

标题
2Drotate(45deg) 默认是z轴
3Drotate3d(45deg,45deg,45deg) rotateX(45deg) rotateY(45deg) rotateZ(45deg)

scale

标题
2Dscale(x,y)
3Dscale3d(x,y,z) scaleX(0.7) scaleY(0.7) scaleZ(0.7)

其他属性

transform-style

transform-style:preserve-3d(具有一个3d效果)

transform-origin

设置坐标原点。旋转,移动,伸缩的原点。
transform-origin: x-axis y-axis z-axis

persective

设置在父元素里面,只对子元素起作用

CSS动画

animation动画

标题
animation-name动画名称
animation-duration动画持续时间,以s为单位,如果不设置,动画不会展示
animation-timing-function动画运动曲线(ease,linear,ease-out,ease-in)
animation-delay延迟时间,以s为单位
animation-iteration-count动画的执行次数,infinity(无限次)
animation-directionnormal(正常,左->右) reverse(反过来,右->左) alternate(左->右->左) alternate-reverse(右->左->右)
animation-fill-mode动画结束时的状态forwards(以最后帧为结束状态),backwards(以开始帧为结束状态)
animation-play-staterunning(运行) paused(暂停)

transition动画

标题
transition-property具有过渡效果的属性,默认为all
transition-duration过渡效果持续时间
transition-timing-function过渡效果的速度曲线
transition-delay过渡效果的延迟时间

参考链接

CSS3-animation动画详解
CSS transform属性