jQuery書架式圖片鼠標滑過縮放顯示



63 251 84



特效描述:jQuery 書架式圖片 鼠標滑過 縮放顯示,jQuery書架式圖片鼠標滑過縮放顯示

代碼結構

1. HTML代碼

<div id="bookrack">
    <a href="#" title="圖片1"><img src="img/1.jpg" alt="jquery" /></a>
    <a href="#" title="圖片2"><img src="img/2.jpg" alt="jquery" /></a>
    <a href="#" title="圖片3"><img src="img/3.jpg" alt="jquery" /></a>
    <a href="#" title="圖片4"><img src="img/4.jpg" alt="jquery" /></a>
    <a href="#" title="圖片5"><img src="img/5.jpg" alt="jquery" /></a>
    <a href="#" title="圖片6"><img src="img/6.jpg" alt="jquery" /></a>
    <a href="#" title="圖片7"><img src="img/7.jpg" alt="jquery" /></a>
    <a href="#" title="圖片8"><img src="img/8.jpg" alt="jquery" /></a>
    <a href="#" title="圖片9"><img src="img/9.jpg" alt="jquery" /></a>
</div>
<script type="text/javascript">
var Bookrack = function(a, b, c, e) {
    this.scale = e || 0.4;
    this.x = b || 120;
    this.y = c || 160;
    this.border = 2;
    this.init(a);
    this.exec(Math.ceil(Math.random() * this.imgs.length))
};
Bookrack.prototype = {
    init: function(a) {
        this.width = a.clientWidth - 2 * this.x * this.scale;
        a.style.position = "relative";
        a.style.height = this.y + "px";
        this.imgs = a.getElementsByTagName("a");
        var b = this,
        c = document.createElement("span"),
        e,
        d;
        this.each(function(a, g) {
            a.style.position = "absolute";
            a.style.bottom = "0";
            a.style.border = this.border + "px solid gray";
            a.style.left = this.width * (g / this.imgs.length) + 2 * this.border + "px";
            a.setAttribute("dir", g);
            d = a.getElementsByTagName("img")[0].getAttribute("alt").split("|");
            e = c.cloneNode(!0);
            e.innerHTML = a.getAttribute("title");
            a.appendChild(e);
            a.onmouseover = function() {
                b.exec(this.getAttribute("dir"))
            }
        })
    },
    each: function(a) {
        for (var b = 0,
        c; c = this.imgs[b++];) a.call(this, c, b, this.imgs.length)
    },
    color: function(a) {
        a = (~~ (255 * a)).toString(16);
        2 > a.length && (a = "0" + a);
        a = a.substr(0, 2);
        return "#" + a + a + a
    },
    exec: function(a) {
        this.each(function(b, c, e, d, f) {
            b.getElementsByTagName("span")[0].style.display = "none";
            c == a && (b.getElementsByTagName("span")[0].style.display = "block");
            d = Math.min(c / a, a / c);
            f = Math.sin(90 * (Math.PI / 180) * d) * (1 - this.scale);
            b.style.zIndex = Math.ceil(1E4 * f);
            b.style.borderColor = this.color(f + this.scale);
            b.style.width = this.x * (f + this.scale) - 2 * this.border + "px";
            b.style.height = this.y * (f + this.scale) - 2 * this.border + "px";
            b.style.marginLeft = this.x * f / -2 + "px"
        })
    }
};
new Bookrack(document.getElementById('bookrack'), 120, 160);
</script>



用戶評論
大牛,別默默的看了,快登錄幫我點評一下吧!:)      登錄 | 注冊


熱門標簽: 滾動切換 滾動條切換 滑動選項卡 滑動切換 flash焦點圖 flash幻燈片 flashbanner flash圖片輪播 選項卡切換 選項卡 切換 tab切換 頁面切換 選項卡插件 切換插件 滑動手風琴 滑動星星打分 焦點圖 幻燈片 輪播圖 bar焦點圖 其他 帶標題的焦點圖 圖片切換 圖片選項卡 圖標選項卡 縮放切換 鼠標滑過 鼠標懸停 跟隨鼠標移動
?
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

jQuery/js討論群
群號:642649996
Css3+Html5討論群
群號:322131262

加群請備注:從官網了解到

老夫子电子