<!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>