0

我有一个简单的html,如下所示,我添加了样式溢出:隐藏以停止浏览器滚动,它适用于除windows版本的chrome之外的所有浏览器请帮助我?

<body style="background-color:yellow; overflow: hidden;">

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
.
.
.
dddddddddddddddddddd
</body>
</html>
4

3 回答 3

9

Overflow hidden, should be working in all browsers. Set it on the body tag. Like:

<body style="overflow: hidden; position: fixed;">
Your content.
</body>

I tried this on Google Chrome and it works.

于 2013-10-10T19:46:02.993 回答
0

你不应该把它放在身体上。您需要在要限制的元素上设置一个高度以隐藏任何溢出。这是一个例子http://jsfiddle.net/tP7qt/

<div style="background-color:yellow; overflow: hidden; height:150px;">
<br>
 more stuff below.  
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 .
 .
 .
 Stuff here
 </div>
 </html>
于 2013-10-10T20:07:45.607 回答
-2

HTML 元素的实际问题是该overflow:hidden属性仅适用于具有非静态位置的元素。

所以,把它放在你的身上:

body {
  overflow: hidden;
  position: relative;
}
于 2013-10-10T20:10:20.237 回答