css滑动div不流畅怎么回事

html-css013

css滑动div不流畅怎么回事,第1张

css滑动div不流畅是因为使用了scroll属性。根据查询相关信息,div或模块使用了overflow:scroll属性,在iOS系统的手机上浏览时,则会出现明显的卡顿现象,但是在android系统的手机上则不会出现该问题。以下代码可解决这种卡顿的问题:-webkit-overflow-scrolling:touch。,是因为这行代码启用了硬件加速特性,所以滑动很流畅。这个方法的确可以解决以后系统的滑动卡顿问题。

<div id="a1"></div><div id="a2"></div><div id="a3"></div>//引入jQuery.js<script>var t1=$("#a1").offset().topvar t1=$("#a2").offset().topvar t1=$("#a3").offset().top

$(window).scroll(function(){var top=$(window).scrollTop()if(top>t1&&top<t2){

$("#a1").addClass("an1")

}if(top>t2&&top<t3){

$("#a2").addClass("an1")

}if(top>t3){

$("#a3").addClass("an1")

}

})</script>