2012-04-17 42 views
0

真的很抱歉,如果这已经被问过,但我已搜查高和低的asnwer现在发现一个...jQuery的 - 的mouseenter内容推送下来

在我的网站,我有一个“页脚”和“底部”。当用户悬停在网站的底部时,我想要显示页脚。我已经能够成功地做到这一点(代码如下)。但是,当用户悬停在“底部”div上时,页脚向下扩展,因此用户必须向下滚动才能看到出现的内容。不是一个巨大的问题,但对用户来说并不是很好。如果站点在显示页脚时推动起来会更好。有谁知道我该怎么做?它只是一个CSS tweek到页脚div吗?预先感谢所有。这是伟大的论坛!

$(document).ready(function(){ 
$("#bottom").mouseenter(function(){ 
     $("#footer").stop(true,true).slideDown(function(){ 
     $("#bottom").addClass("open"); 
     }); 
    }); 
    $("#footer, #bottom").mouseleave(function(){ 
    $("#footer").stop(true,true).delay(1000).slideUp(function(){ 
     $("#bottom").removeClass("open"); 
    }); 
    }); 
    $("#footer").mouseenter(function(){ 
    $("#footer").stop(true,true).slideDown(); 
    }); 
}); 


#footer { 
display:none; 
height: 200px; 
} 
#bottom 
{ 
height: 30px; 
} 

回答

2

尝试

$('html, body').animate({scrollTop: $(document).height()}, 200); 

的了slideDown函数的回调中。
这将滚动文档到底部。

看评论:

var event = window.setInterval(function() { 
    $('html, body').animate({scrollTop: $(document).height()}, 50); 
}, 50); 
$("#footer").stop(true,true).slideDown(function(){ 
    $("#bottom").addClass("open"); 
    window.clearInterval(event); 
    }); 
+0

哇感谢你,真实工作一种享受! 感谢您的快速响应。 绝对喜欢这个论坛。没有精英主义和真正有帮助的人的伟大答案。干杯! – 30secondstosam 2012-04-17 20:32:06

+0

我想说,虽然它运行得非常好,但它仍然有点让页面JUMP,它会很好,因为它是光滑的,只是把它移动它,但谢谢你,这是一个JavaScript的东西,我们什么也没有对,对吗? – 30secondstosam 2012-04-17 20:35:11

+0

那么,你可以做到这一点,但它可能会吃掉一些表现。我将用示例代码编辑anser ... - 更新 - 这可能包含语法错误tho' - 它将每50毫秒执行一次滚动) – bardiir 2012-04-17 20:42:47