css3动画
2016-02-28 20:16
363 查看
CSS动画分为Transition功能和Animations功能
Transition功能支持从一个属性值平滑过渡到另一个属性值:在样式代码中,如果使用Firefox浏览器,需要写成“-moz-transition”的形式;如果使用Opera浏览器,需要写成“-o-transition”形式;如果使用的是Safari或者是Chrome浏览器,需要写成“-webkit-transtion”形式。
transtion属性使用方法:transition:property duration timing-function
property表示要进行平滑过渡的属性,duration完成过渡的时间,timing-function表示通过什么方法完成过渡
同时过渡多个属性:property1 duration1 timing-function1,property2 duration2 timing-function2
不同属性之间用“,”隔开
Animations功能与Transitions功能相同,只是可以实现更复杂的动画。
Animations使用示例:
也可以实现多个属性值同时改变,例子如下:
Transition功能支持从一个属性值平滑过渡到另一个属性值:在样式代码中,如果使用Firefox浏览器,需要写成“-moz-transition”的形式;如果使用Opera浏览器,需要写成“-o-transition”形式;如果使用的是Safari或者是Chrome浏览器,需要写成“-webkit-transtion”形式。
transtion属性使用方法:transition:property duration timing-function
property表示要进行平滑过渡的属性,duration完成过渡的时间,timing-function表示通过什么方法完成过渡
同时过渡多个属性:property1 duration1 timing-function1,property2 duration2 timing-function2
不同属性之间用“,”隔开
Animations功能与Transitions功能相同,只是可以实现更复杂的动画。
Animations使用示例:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> div{ background-color: red; } @-webkit-keyframes myPlay { 0%{ background-color:red ; } 50%{ background-color:green; } 100%{ background-color:red; } } div:hover{ -webkit-animation-name:myPlay ; -webkit-animation-duration:3s; -webkit-animation-timing-function: linear ; } </style> </head> <body> <div>演示</div> </body> </html>
也可以实现多个属性值同时改变,例子如下:
div{ background-color: red; width:200px; height: 200px; } @-webkit-keyframes myPlay { 0%{ background-color:red ; width: 200px; } 50%{ background-color:green; width:300px; } 100%{ background-color:red; width: 200px; } } div:hover{ -webkit-animation-name:myPlay ; -webkit-animation-duration:3s; -webkit-animation-timing-function: linear ; }
相关文章推荐
- css05 字体以及行间距
- 实用的css3属性
- 【html/css】选择器以及其优先级的问题
- css基础
- CSS样式之clear清除浮动
- CSS 颜色代码大全
- css全局设置
- CSS技巧: CSS隐藏文字的方法(CSS text-indent: -9999px;)
- CSS——你所不知的 CSS ::before 和 ::after 伪元素用法(转)
- CSS——伪元素
- CSS小技巧总结
- C#学习之css(二)
- css学习(一)-CSS基础、css选择器
- Demo12:书册子旋转
- 样式化的定型对象Style样式的定义
- CSS框模型(Box Model)初学理解
- CSS3 入门6
- CSS3 入门5
- CSS3 入门4
- CSS3 入门3