【发布时间】:2014-04-25 12:21:33
【问题描述】:
我正在尝试创建一个在 iPhone/Android 设备上感觉像原生应用的网站。
我已经设法设置它,所以 html 和 body 不会滚动,我有一个单一的内容 <div> 这是可滚动的部分。
但是,当设置
overflow-x:hidden
为了只允许垂直滚动,我仍然可以在 iPhone(Chrome 和 Safari)上获得水平滚动行为。您可以看到滚动条属于 .content 元素。设置
overflow:hidden
按预期工作并禁用所有滚动。
对我来说,这看起来像是 Chrome 上的一个错误。
代码:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
.scroll {
height: 100%;
overflow-y: auto;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
}
.content {
height: 2000px;
margin: 10px;
overflow-x: hidden;
background: linear-gradient(to bottom, #f00 0%, #00f 50%);
}
</style>
</head>
<body>
<div class="scroll">
<div class="scroll">
<div class="content">
<div style="height: 20px; width: 1000px; background: black;"></div>
</div>
</div>
</div>
</body>
</html>
【问题讨论】:
标签: html ios css iphone browser