1.阻止PC端浏览器页面滚动
$('html').css('overflow','hidden')
或
html{
overflow:hidden;
}
2.阻止手机端页面滑动
方法一
$('#bianmincase,.main').bind("touchmove",function(e){
e.preventDefault();
});
方法二
position: fixed;top:0;left: 0;
3.浏览器页面回到顶部
$('html,body').animate({scrollTop:0},100);//回到顶端
或
$(window).scrollTop(0);
本文介绍了如何使用JavaScript和CSS阻止网页在PC和手机端的滚动,提供了多种方法实现页面固定效果。同时,分享了将浏览器页面快速回到顶部的实用代码。
674

被折叠的 条评论
为什么被折叠?



