Safari-IPAD-禁用反弹(无滚动)而不使用-webkit溢出滚动



首先,我在web中测试了很多解决方案,但所有的解决方案都不起作用。

我有一个带有Iframe的网页,里面有一个divoverflow:hidden,还有一个divoverflow:scroll

当我想滚动到包含在Iframe中的div时,反弹断了所有。每次滚动后都会出现反弹,内容也会一点一点地出现。

我想禁用弹跳,但不想滚动。我不想使用-webkit-overflow-scrolling。因为在应用-webkit-overflow-scrolling之后,我的页面中所有的溢出都是溢出:auto,这对我来说不是一个好方法。

我尝试过这个解决方案,但它不好,并且禁用了滚动:

var xStart, yStart = 0;
document.addEventListener('touchstart',function(e) {
    xStart = e.touches[0].screenX;
    yStart = e.touches[0].screenY;
});
document.addEventListener('touchmove',function(e) {
    var xMovement = Math.abs(e.touches[0].screenX - xStart);
    var yMovement = Math.abs(e.touches[0].screenY - yStart);
    if((yMovement * 3) > xMovement) {
        e.preventDefault();
    }
});

你可以查看我说的话,请查看我的页面:http://cipa.ch/forStack/

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
		<meta name="viewport" content="width=640">
	</head>
	<body  style="margin:0;padding:0;">
		<iframe frameborder="0" height="100%" width="100%" style="margin:0;padding:0;width:100%;height:90%;position:absolute" src="http://cipa.ch/forStack/test.html" >
		</iframe>
	</body>
</html>

尝试在body标签上添加position:fixed

body {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

最新更新