案例:開機影片
由上下兩部分組成,先下面的高變為0 ,再最大的div寬為0,形成一個縮小到沒有的影片效果
點擊的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>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/160792.html
標籤:JavaScript
下一篇:高維護性的JavaScript
