CSS3使用备忘

animation动画:

animation 属性是一个简写属性,共有六个动画属性

 

描述
animation-name 规定需要绑定到选择器的 keyframe 名称。。
animation-duration 规定完成动画所花费的时间,以秒或毫秒计。
animation-timing-function 规定动画的速度曲线。
animation-delay 规定在动画开始之前的延迟。
animation-iteration-count 规定动画应该播放的次数。
animation-direction 规定是否应该轮流反向播放动画。

 一般应用时,需要先设置个需要变化的属性,比如width:100px,然后设置个hover等动作去激活动画,加入需要变化的属性width:300px,并引入下面动画属性

CSS代码
  1. -webkit-transition: all 0.4s ease 0s;  
  2. -moz-transition: all 0.4s ease 0s;  
  3. -ms-transition: all 0.4s ease 0s;  
  4. -o-transition: all 0.4s ease 0s;  
  5. transition: all 0.4s ease 0s;  

all 意思是包含了所有要变化的属性,有些是变化背景色的background等等。这里可以把all换成width一样执行,0.4s是动画执行的时间,ease是动画的运行方式,最后的0s是指激活后播放动画延时时间。

 

需要执行多个动作:

XML/HTML代码
  1. -webkit-transition: padding 0s linear, color .5s ease-in-out, background-color .5s ease-in-out;   
  2.    
  3. -o-transition: padding 0s linear, color .5s ease-in-out, background-color .5s ease-in-out;    
  4.   
  5. transition: padding 0s linear, color .5s ease-in-out, background-color .5s ease-in-out;   

transform: scale(1.2) rotate(2deg);   放大并旋转  

scale:放大的倍数,可以用负数,即缩小。 

rotate:旋转的角度 2deg是2度

未经允许不得转载:Windy's Blog » CSS3使用备忘

赞 (0)