注:例子和截图均参考菜鸟教程,地址:http://www.runoob.com/cssref/css3-pr-animation.html
1.html
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0">
<title>菜鸟教程(runoob.com)</title>
<style>
div {
width: 100px;
height: 100px;
background: red;
position: relative;
/*需做兼容处理*/
animation: mymove 5s infinite;
-webkit-animation: mymove 5s infinite;
-moz-animation: mymove 5s infinite;
}
/*@keyframes定义动画名称*/
@keyframes mymove {
from {
left: 0px;
}
to {
left: 200px;
}
}
@-webkit-keyframes mymove{
from {
left: 0px;
}
to {
left: 200px;
}
}
@-moz-keyframes mymove{
from {
left: 0px;
}
to {
left: 200px;
}
}
</style>
</head>
<body>
<p><strong>注意: </strong> Internet Explorer 9 及更早IE版本不支持 animation 属性。</p>
<div></div>
</body>
</html>
2.语法(支持简写)
animation: name duration timing-function delay iteration-count direction fill-mode play-state;
值 | 说明 |
---|---|
animation-name |