实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<style> 
5
#myDIV {
6
    height: 200px;
7
    background-color: lightblue;
8
    border: 1px solid black;
9
    animation: mymove 5s infinite;
10
    -webkit-animation: mymove 5s infinite; /* Chrome, Safari, Opera */
11
}
12
13
/* Chrome, Safari, Opera */
14
@-webkit-keyframes mymove {
15
    50% {margin-left: 50px;}
16
}
17
18
/* Standard syntax */
19
@keyframes mymove {
20
    50% {margin-left: 50px;}
21
}
22
</style>
23
</head>
24
<body>
25
26
<p>逐步改变 margin-left, 从 0px 到 50px :<p>
27
<div id="myDIV">
28
This is my DIV element.
29
</div>
30
31
<p>margin-left 属性支持动画效果。</p>
32
<p><b>注意:</b>Internet Explorer 9 及更早 IE 版本不支持 CSS 动画。</p>
33
34
</body>
35
</html>
36