CSS3变形、过渡与动画

2016-10-26  本文已影响0人  白小九

一、变形

应用2D或3D变换
transform: none | <fn>+; /*  默认为none */
<fn>之移动
translate(<tx> [ ,<ty> ]?)  /* 2D */
translate3d(<tx>, <ty>, <tz>)  /* 3D */
/* 沿x轴移动<tx> = <len-%>,
  沿y轴移动<ty> = <len-%>,
  沿z轴移动<tz> = <length>。
 */
<fn>之旋转
rotate(<angle>)  /* 2D,围绕z轴旋转 */
rotate3d(<x>, <y>, <z>, <angle>)  /* 3D,以(x,y,z)与原点的连线为轴旋转 */
<fn>之倾斜
skew(<x-angle> [ ,<y-angle> ]?)  /* 只有2D */
<fn>之缩放
scale(<x-num>[,<y-num>]?)  /* 2D,y值缺省时应用x值 */
scale3d(<x-num>, <y-num>, <z-num>)  /* 3D */
变形原点
transform-origin: <x> <y>? <z>?; /*  省略<z>表示2D原点 */
/* x坐标<x> = left | center | right | <len-%>,
  y坐标<y> = top | center | bottom | <len-%>,
  z坐标<z> = <length>,
  <len-%> = <length> | <%>。
 */
子元素是否保留3D样式
transform-style: flat | preserver-3d;
3D透视
perspective: none | <num>; /* 透视距离 */
perspective-origin: <x> <y>?; /* 透视角度 */
元素背面可见
backface-visibility: visible | hidden;

二、过渡

指定应用过渡效果的CSS属性
transition-property: none | <prop>#;
/* <prop> = all | <IDENT> */
过渡持续时长
transition-duration: <time>#;
延迟过渡时长
transition-delay: <time>#;
过渡的速度曲线
transition-timing-function: <timing-fn>#;
/* <timing-fn> = linear | <cubic-bezier-fn> | <step-fn> | <frames-fn>,
  <cubic-bezier-fn> = ease | ease-in | ease-out | ease-in-out | cubic-bezier(<n>,<n>,<n>,<n>),
  <step-fn> = step-start | step-end | steps(<int> [ , [ start | end ] ]?),
  <frames-fn> = frames(<int>)。
 */
属性简写
transition: [ none | <prop> ] || <time> || <timing-fn> || <time>;

三、自定义动画

动画名称
animation-name: <name>#;
/* <name> = none | <IDENT> */
动画持续时长
animation-duration: <time>#;
延迟动画时长
animation-delay: <time>#;
动画的速度曲线
animation-timing-function: <timing-fn>#;
动画执行次数
animation-iteration-count: <count>#;
/* <count> = infinite | <num> */
动画执行方向
animation-direction: <direction>#;
/* <direction> = normal | reverse | alternate | alternate-reverse */
动画执行状态
animation-play-state: <play-state>#;
/* <play-state> = running | paused */
动画执行前后的样式
animation-fill-mode: <fill-mode>#;
/* <fill-mode> = none | forwards | backwards | both */
关键帧
@keyframes <identifier> {
    [ <keyframes-selector> {<css-styles>;} ]*
}
/* <keyframes-selector> = [ from | to | <%> ]# */
属性简写
animation: [ <name> || <time> || <timing-fn> || <time> || <count> || <direction> || <fill-mode> || <play-state> || [ none | <identifier> ] ]#;
上一篇 下一篇

猜你喜欢

热点阅读