<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css"> <script src="/jquery/jquery-1.11.1.min.js"></script> <script src="//apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var div=$("div"); div.animate({width:'300px',opacity:'1'},"slow"); div.animate({width:'200px',opacity:'0.5'},"slow"); }); }); </script> </head> <body> <button>開始動畫</button> <p>默認狀況下,全部 HTML 元素的位置都是靜態的,而且沒法移動。如需對位置進行操做,記得首先把元素的 CSS position 屬性設置爲 relative、fixed 或 absolute。</p> <div style="background:#98bf21;height:100px;width:20px;position:absolute;opacity:0;color:#fff;font-size:20px;"> <i class="glyphicon glyphicon-stop" style="color:#fff;font-size:20px;"></i> </div> </body> </html>