由上下兩部分組成,先下面的高變爲0 ,再最大的div寬爲0,造成一個縮小到沒有的動畫效果html
點擊的X是在背景圖上的,在上面設置了一個空的span用於註冊點擊事件函數
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> .box { width: 322px; position: fixed; bottom: 0; right: 0; overflow: hidden; } span { position: absolute; top: 0; right: 0; width: 30px; height: 20px; cursor: pointer; } </style> </head> <body> <div class="box" id="box"> <span id="closeButton"></span> <div class="hd" id="headPart"> <img src="images/t.jpg" alt="" /> </div> <div class="bd" id="bottomPart"> <img src="images/b.jpg" alt="" /> </div> </div> <script src="common.js"></script> <script> my$("closeButton").onclick = function () { //設置最下面的div高漸漸變爲0,裏面加個回掉函數 animate(my$("bottomPart"), { "height": 0 }, function () { animate(my$("box"), { "width": 0 }); }); }; </script> </body> </html>