开发者

How to force the horizontal scroll bar to appear?

开发者 https://www.devze.com 2023-03-02 10:28 出处:网络
Consider t开发者_Python百科he following code: HTML: <div id=\"wrapper\"> <div class=\'a\'></div>

Consider t开发者_Python百科he following code:

HTML:

<div id="wrapper">
    <div class='a'></div>
    <div class='a'></div>
    <div class='a'></div>
    <div class='a'></div>
    <div class='a'></div>
</div> 

CSS:

#wrapper {
    width: 300px;
    border: 1px solid black;
    overflow: auto;
}
.a {
    width: 70px;
    height: 70px;
    border: 1px solid red;
    float: left;
}   

How could I force the horizontal scroll bar to appear rather than displaying the red div's in the second line ?


Try this:

#wrapper {
  width: 300px;
  border: 1px solid black;
  overflow: auto;
  white-space: nowrap;
}
.a {
  width: 70px;
  height: 70px;
  border: 1px solid red;
  display: inline-block;
}

It will give you spacing between the inner divs - put them all in one line to remove those.

0

精彩评论

暂无评论...
验证码 换一张
取 消