繁体   English   中英

调整jQuery滑动框的悬停区域

[英]Tweaking hover area for jQuery sliding boxes

我正在使用一些jQuery创建3个框,将它们悬停并向上滑动以显示更多内容。 我的两个问题是:

1)我该如何调整,以便仅将鼠标悬停在灰色框上才能激活幻灯片,而不是激活灰色框上方的整个不可见区域?

2)有没有更好的方法可以做到这一点? 我是JavaScript的初学者,并且一起破解了我在Google搜索中发现的一些内容。 例如,最好根据内容自动生成高度,而不是依赖固定高度。

http://jsfiddle.net/kUjax/

$(document).ready(function(){
    $('.boxgrid.caption').hover(function(){
        $(".cover", this).stop().animate({top:'120px'},{queue:false,duration:150});
    }, function() {
        $(".cover", this).stop().animate({top:'210px'},{queue:false,duration:150});
    });
});

您几乎自己做了:

$(document).ready(function () {
    $('.boxgrid .boxcaption').hover(function () {
        $(this).stop().animate({top: '120px'}, {
            queue: false,
            duration: 150
        });
    }, function () {
        $(this).stop().animate({top: '210px'}, {
            queue: false,
            duration: 150
        });
    });
});

http://jsfiddle.net/kUjax/1/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM