码迷,mamicode.com
首页 > Web开发 > 详细

CSS3动画效果animation

时间:2017-05-09 19:39:51      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:inf   strong   doctype   scale   doc   form   exp   元素   支持   

利用CSS中animation为元素添加动画,代码格式为:

animation:动画名 .75s infinite;
-webkit-animation:动画名 .75s infinite; /*Safari and Chrome*/

第二句是为了兼容谷歌浏览器等,在指定动画时需要将元素指定为相对定位:position:relative;

接着为动画指定效果:

@keyframes 动画名
{
from {transform: none;}
to {transform: scale(1.6);}
}

@-webkit-keyframes 动画名
{
from {-webkit-transform: none;}
to {-webkit-transform: scale(1.6);}
}

 

 

完整例子:

效果链接:http://www.w3school.com.cn/tiy/t.asp?f=css3_animation

<!DOCTYPE html>
<html>
<head>
<style>
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove 5s infinite;
-webkit-animation:mymove 5s infinite; /*Safari and Chrome*/
}

@keyframes mymove
{
from {left:0px;}
to {left:200px;}
}

@-webkit-keyframes mymove /*Safari and Chrome*/
{
from {left:0px;}
to {left:200px;}
}
</style>
</head>
<body>

<p><strong>注释:</strong>Internet Explorer 9 以及更早的版本不支持 animation 属性。</p>

<div></div>

</body>
</html>

CSS3动画效果animation

标签:inf   strong   doctype   scale   doc   form   exp   元素   支持   

原文地址:http://www.cnblogs.com/lexin593119348/p/6832085.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!