css - Bootstrap : How to create a series of div on one line hiding the overflowing divs

标签 css twitter-bootstrap

我有一个使用 bootstrap 构建的网站,我想使用 jquery.dragscroll 插件创建一个带有可滑动标题的表,但保留内置的 bootstrap 的流体网格。

所以我想创建表格的标题,我正在使用这个 HTML:

<div class="row-fluid">
    <div class="span12">
        <div style="overflow:hidden;width:90%;">
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
            <div style="display:inline-block;width:100px">some content</div>
        </div>
    </div>
</div>

代码在这里:http://jsfiddle.net/cVfzJ/1/

正如我们在 Fiddle 中看到的那样,所有的 div 在两行中都是可见的,我的目标是将所有的 div 放在一行中( overflow hidden 的 div)

我希望问题很清楚

最佳答案

你应该有一个容器来容纳所有 <div>width等于所有 <div> 的总和.那么这个容器的父容器必须有 overflow: auto .

如果您不知道渲染前的总宽度,您可以使用 JS 来计算它。

继续你的例子:

<div class="row-fluid">
    <div class="span12">

        <!-- Changed from `hidden` to `auto`. -->
        <div style="overflow:auto;width:90%;">

            <!-- This is the div that does the trick: -->
            <div style="width:1200px;">

            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>
            <div style="display:inline-block;width:100px;">some content</div>

            </div>

        </div>
    </div>
</div>

关于css - Bootstrap : How to create a series of div on one line hiding the overflowing divs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16773990/

相关文章:

jquery - jCarousel Lite - 水平和垂直居中图像

jquery - 使用 jquery 更改具有多个值的单个变量

jquery - 如何在 css3 或 jquery 中将背景图像加载为滚动

twitter-bootstrap - 如何将 Twitter Bootstrap CSS 和 Javascript 集成到普通 VueJS 项目中?

jquery - 带有流畅的 Twitter Bootstrap 的可折叠侧边栏

javascript - 根据 ng-grid selectedItem[0] 更改下拉选项

javascript - 带有javascript的单选按钮样式

javascript - Bootstrap 工具提示位置被长文本搞乱了

html - 动态对齐 :after according to parent length

jquery动画与手机