关于移动端h5页面不能滑动问题的解决办法

页面不能滑动无非就是css和js两个方面的问题


有的人说如果我写很多个p标签不写任何样式看能不能滑动,如果能滑动说明是样式的原因,要是也不能滑动那就应该是js的原因,是有一定的道理的,但是先别忘了看一下你的html或body是不是加了height:100%;overflow:hidden;

1.下面分先说css的问题,主要排查overflow:hidden;

检查也有一定的顺序,检查超出高度的标签是否用了overflow:hidden;最好先检查html或body是不是加了height:100%;overflow:hidden;然后再看包裹在最外边的元素是否加了overflow:hidden;


2.再说下js方面的问题,主要是有在touchstart、touchmove或touchend等事件中的阻止默认事件的原因

例如:$("#myCarousel").on("touchstart", function (e) {

                     e.preventDefault();   

                     startX = e.originalEvent.changedTouches[0].pageX,
                    startY = e.originalEvent.changedTouches[0].pageY;

          });

这种代码其中e.preventDefault();会阻止掉默认的滚动行为。



你可能感兴趣的:(关于移动端h5页面不能滑动问题的解决办法)