只有在溢出时才会看到滚动条

时间:2014-02-25 08:09:46

标签: css3 html overflow

只有当存在溢出时才能看到滚动条,否则它应该被隐藏。但是默认情况下它显示滚动条,尽管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;
}

1 个答案:

答案 0 :(得分:2)

overflow:auto;会这样做。

div.scroll
{
  background-color:#00FFFF;
  width:100px;
  height:100px;
  overflow:auto;
}