頁(yè)面文檔載入后,為第一張圖片添加class屬性值為img1,為第二張圖片添加class屬性值img2,為第三張圖片添加class屬性img3,為第四張圖片添加class屬性值img4,這會(huì)使得每張圖片的下半部分被上一張更大的圖片給覆蓋住。
當(dāng)鼠標(biāo)單擊暴露在最上面的圖片時(shí),該圖片在0.6秒內(nèi)從原本大小放大150%,并逐漸減小不透明度直到完全消失,與此同時(shí),其他所有圖片在0.6秒內(nèi)動(dòng)態(tài)的放大并占據(jù)相應(yīng)上一張圖片的位置。全部動(dòng)態(tài)效果結(jié)束后,消失不見(jiàn)的那張圖片重新顯示在最下面。
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>jQuery UI</title> <style type="text/css"> div{ position: relative; } img{ position: absolute; border:solid 3px black; } .img1{ width: 300px; height: 220px; top:120px; left: 200px; z-index: 4; opacity:1; cursor:pointer; } .img2{ width: 200px; height: 145px; top:85px; left: 250px; z-index: 3; opacity: 0.7; } .img3{ width: 120px; height: 90px; top:60px; left: 290px; z-index: 2; opacity: 0.5; } .img4{ width: 60px; height: 55px; top:45px; left: 320px; z-index: 1; opacity: 0.4; } </style> <script type="text/javascript" src="jquery-1.5.2.min.js"></script> <script type="text/javascript" src="jquery.effects.core.min.js"></script> <script type="text/javascript" src="jquery.effects.scale.min.js"></script> <script type="text/javascript"> $(function(){ $('img').each(function(index){ $(this).addClass('img'+(index+1)); }); $('img.img1').live('click',function(){ $(this).hide('puff',{percent:150},600,function(){ $(this).attr('class','img4').show(); }); $('img.img2').switchClass('img2','img1',600); $('img.img3').switchClass('img3','img2',600); $('img.img4').switchClass('img4','img3',600); }); }); </script></head><body> <div> <img src="1.jpg"> <img src="2.jpg"> <img src="3.jpg"> <img src="4.jpg"> </div></body></html>初始效果:

點(diǎn)擊后效果:

新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注