只有当存在溢出时才能看到滚动条,否则它应该被隐藏。但是默认情况下它显示滚动条,尽管div具有适当的非溢出内容。 我们怎么能阻止它?
<body>
<p>The overflow property specifies what to do if the content of an element exceeds the size of the element's box.</p>
<p>overflow:scroll</p>
<div class="scroll">You can use the overflow property when you want to have better control of the layout. The default value is visible.</div>
</body>
CSS:
div.scroll
{
background-color:#00FFFF;
width:100px;
height:100px;
overflow-x:scroll;
}
答案 0 :(得分:2)
overflow:auto;
会这样做。
div.scroll
{
background-color:#00FFFF;
width:100px;
height:100px;
overflow:auto;
}