制作思路:“放大鏡”后有一幅背景圖,它是“放大了”的圖的原本。我們通過(guò)移動(dòng)“放大鏡”時(shí)適當(dāng)調(diào)整背景圖的位置,使它顯示的剛好是需要要放大的部分。
效果演示: (點(diǎn)這里在新窗口中查看)
制作步驟:
1)先準(zhǔn)備兩幅內(nèi)容相同尺寸不同的圖片,這里我們找了一個(gè)400×300像素的縮略圖small_hill.gif,一個(gè)800×600像素的大圖big_hill.gif。然后再準(zhǔn)備一個(gè)“放大鏡”的圖片,注意它中間部分必須是透明的,這里我們準(zhǔn)備了一個(gè)綠色的方框 viewer.gif。
2)編寫(xiě)如下的代碼:
以下是兩幅圖的代碼,都它們作為層。第一幅是縮略圖,第二幅是“放大鏡”,首先將它的背景移到不可見(jiàn)的地方; 其中“ onclick="moveme=!moveme" ”表示每次點(diǎn)擊它都改變“moveme”的布爾值。
以下是JavaScript腳本: 聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com"small_hill.gif"https://www.gxlcms.com/ id=https://www.gxlcms.com/"bgLayer"https://www.gxlcms.com/ style=https://www.gxlcms.com/"position:absolute; left:150px; top:50px;"https://www.gxlcms.com/>
"viewer.gif"https://www.gxlcms.com/ id=https://www.gxlcms.com/"myviewer"https://www.gxlcms.com/ onclick=https://www.gxlcms.com/"moveme=!moveme"https://www.gxlcms.com/ onmousemove=https://www.gxlcms.com/"viewit(this)"https://www.gxlcms.com/
style=https://www.gxlcms.com/"left:0;top:0;background-repeat:no-repeat; background-position:2000px 2000px;position:absolute;"https://www.gxlcms.com/>https://www.gxlcms.com/