0

真的很抱歉,如果之前有人问过这个问题,但我已经在高处和低处搜索了一个答案,现在找到了一个......

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

$(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;
}
4

1 回答 1

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);
  });
于 2012-04-17T20:12:19.797 回答