CSS3动画属性简单介绍

CSS3的动画属性
下面的表格列出了 @keyframes 规则和所有动画属性:
属性  描述  CSS
@keyframes  规定动画。   3
animation   所有动画属性的简写属性,除了 animation-play-state 属性。 3
animation-name  规定 @keyframes 动画的名称。    3
animation-duration  规定动画完成一个周期所花费的秒或毫秒。默认是 03
animation-timing-function   规定动画的速度曲线。默认是 "ease"3
animation-delay 规定动画何时开始。默认是 03
animation-iteration-count   规定动画被播放的次数。默认是 13
animation-direction 规定动画是否在下一周期逆向地播放。默认是 "normal"3
animation-play-state    规定动画是否正在运行或暂停。默认是 "running"3
CSS3动画是什么?
动画是使元素从一种样式逐渐变化为另一种样式的效果。
您可以改变任意多的样式任意多的次数。
请用百分比来规定变化发生的时间,或用关键词 "from""to",等同于 0% 和 100%0% 是动画的开始,100% 是动画的完成。
为了得到最佳的浏览器支持,您应该始终定义 0% 和 100% 选择器

例子


<html>
<head>
<meta charset="utf-8"> 
<title>title>
<style> 
div
{
    width:100px;
    height:100px;
    background:red;
    position:relative;
    animation-name:myfirst;
    animation-duration:5s;
    animation-timing-function:linear;
    animation-delay:2s;
    animation-iteration-count:infinite;
    animation-direction:alternate;
    animation-play-state:running;
    /* Safari and Chrome: */
    -webkit-animation-name:myfirst;
    -webkit-animation-duration:5s;
    -webkit-animation-timing-function:linear;
    -webkit-animation-delay:2s;
    -webkit-animation-iteration-count:infinite;
    -webkit-animation-direction:alternate;
    -webkit-animation-play-state:running;
}

@keyframes myfirst
{
    0%   {background:red; left:0px; top:0px;}
    25%  {background:yellow; left:200px; top:0px;}
    50%  {background:blue; left:200px; top:200px;}
    75%  {background:green; left:0px; top:200px;}
    100% {background:red; left:0px; top:0px;}
}

@-webkit-keyframes myfirst /* Safari and Chrome */
{
    0%   {background:red; left:0px; top:0px;}
    25%  {background:yellow; left:200px; top:0px;}
    50%  {background:blue; left:200px; top:200px;}
    75%  {background:green; left:0px; top:200px;}
    100% {background:red; left:0px; top:0px;}
}
style>
head>
<body>

<p><b>注意:b> 该实例在 Internet Explorer 9 及更早 IE 版本是无效的。p>

<div>div>

body>
html>

你可能感兴趣的:(CSS3动画属性简单介绍)