html - 内联 block 元素的水平滚动

标签 html css

我有内联 block div,但是当它们到达屏幕末尾时,它们会转到下一行而不是水平滚动,有人可以帮我吗? 这是一个fiddle

<div class="m_wrap">
<div class="dx">
    <div class="xc">1</div>
    <div class="xc">2</div>
    <div class="xc">3</div>
    <div class="xc">4</div>
    <div class="xc">5</div>
    <div class="xc">6</div>
    <div class="xc">7</div>
    <div class="xc">8</div>
    <div class="xc">9</div>
    <div class="xc">10</div>

   </div>
  </div>

CSS

.m_wrap{
width:100%;
height:100px;
}
.dx{
   width:100%;
height:100px;
overflow:scroll;
}
.xc{
display:inline-block;
width:100px;
height:80px;
border:1px solid;
line-height:80px;
text-align:center;
margin-bottom:4px;
 }

最佳答案

dx 类上使用 white-space: nowrap;

Fiddle

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

关于html - 内联 block 元素的水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23235016/

相关文章:

javascript - 以编程方式检查网络资源是否已加载到网页

CSS 下划线小于标题宽度?

php - 如何对齐不同大小的图像

javascript - 如何在 HTML 中更改 ul 标签 css 的属性

html - flexbox 根据容器中的元素数量包装

html - CSS 伪类 :hover and :active not working

jquery - 防止文本超出包含的 <div>

html - 包含 div 的 CSS 内容溢出

css - 页脚位于表格之上。 Bootstrap 3

css - IE11 中的 Flex 元素溢出容器