源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <style> #myDIV { width:300px; height:200px; background:red; animation:mymove 5s infinite; /*Safari 和 Chrome:*/ -webkit-animation:mymove 5s infinite; } @keyframes mymove { from {background-color:red;} to {background-color:blue;} } /*Safari 和 Chrome:*/ @-webkit-keyframes mymove { from {background-color:red;} to {background-color:blue;} } </style> </head> <body> <p>背景顏色逐漸地從紅色變化到藍色:<p> <div id="myDIV"></div> <p>在 CSS 中,background-position 屬性是 <em>可動畫化(animatable)</em> 的。</p> <p>Internet Explorer 10、Firefox 和 Opera 支持 CSS 動畫。</p> <p>Safari 和 Chrome 通過帶有前綴 -webkit-,支持 CSS 動畫。</p> </body> </html>
運行結果