Mozilla滚动条jquery div不滚动

时间:2016-03-28 12:26:38

标签: jquery html mozilla

我有一个带溢出auto的div。

我希望如果用户滚动页面并且如果带有滚动条的div出现,那么它首先滚动该div然后滚动主体滚动条。

在我的情况下,它在chrome中工作正常但在mozilla中,如果你连续滚动页面,它不会滚动该div。

这是我的HTML

<p>lorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem sumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsum</p>


<div class="scroller">

<p>lorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ips</p><p>lorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipmlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsum</p>
</div>
<p>lorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorerem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem </p><p>lorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem ipsumlorem lorem </p>

请建议我。 https://jsfiddle.net/46eejkmw/1/

1 个答案:

答案 0 :(得分:0)

检查这个小提琴:https://jsfiddle.net/fq19n473/1/

你可以使用这个jquery:

var i=0;
var docsc=$(document).scrollTop();
$(document).scroll(function(){
    i+=30;
  var divsc=$('.scroller').scrollTop();
  if(divsc < $('.scroller').height()-31){
    $('html, body').prop("scrollTop", docsc);
    $('.scroller').animate({
        "scrollTop":i
    },100);
  }else{
    i=0;
    docsc=$(document).scrollTop();
  }
});