html - 在显示 :table div? 内水平滚动 div

标签 html css

我可以使用以下方法制作水平滚动的 div:

CSS

.scroll {
    width:100%;
    height:100px;
    overflow-x:auto;
    white-space:nowrap;
}

.box {
    width:200px;
    height:100%;
    display:inline-block;
    vertical-align:top;
}

HTML

<div class="scroll">
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
</div>

但是,一旦它嵌套在带有 display:table 的 div 中,.scroll div 就不再滚动,而是拉伸(stretch) .scroll div 以显示所有框。

很确定有一个简单的解决方法,有什么想法吗?

供引用:http://jsbin.com/makigome/29/edit?html,css,output

最佳答案

试试这个 CSS,希望对你有帮助

.table {
  display: block;
  width:100%;
}

.table-cell {
  display:block;
  width:100%;
}

.scroll {
  height:100px;
  width:100%;
  overflow-x:auto;
  border:1px solid red;
  white-space:nowrap;
  margin:10px 0px;
}

.box {
  width:200px;
  height:100%;
  background:orange;
  display:inline-block;
  vertical-align:top;
}

关于html - 在显示 :table div? 内水平滚动 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23376182/

相关文章:

html - 网站布局问题

html - 嵌套的 flexbox 行换行顺序?

javascript - 如何刷新 select by javascript 或 jquery 中的默认显示选项?

html - 我的一个页面上有多个 HTML5 flowplayer。我怎样才能让他们互相排斥呢?

html - 如何仅使用 <div> 标签和 Css 创建表

CSS - 如何使用非圆形百分比设置多个 div 宽度以填充父 div 空间

使用内联 block div 的 CSS 列

html - Bootstrap 密码部分在点击时损坏

css - 无法垂直居中对齐图像元素

html - 当我点击刷新时,它变成了一半可见