css - Bootstrap : Force columns to stack up vertically on mobile (responsive design)

标签 css twitter-bootstrap

我有以下代码:

<div class='carousel'>
    <div class='data-ng-repeat='{{ repeat }}'{% endif %}>
        <div class='col-xs-12 col-sm-3 vdivide valign-wrap' data-ng-repeat='i in items'>
          <div class='valign'>
            <p class='body'>
              <span> {$ i.statistic $} </span>
              <span> {$ i.text $} </span>
            </p>
          </div>
        </div>
       </div>
</div>

使用以下 CSS:

.vdivide:not(:last-child) {
    border-right: 1px solid rgba(196, 187, 159, 0.63);
}
.carousel {
   height: 300px;
}

因此我有 4 列,用横线分隔它们。 当我切换到移动屏幕时,我希望它们能很好地堆叠起来。 知道我怎么能用 bootstrap 做到这一点吗?

最佳答案

除了使用正确的列类名称外,您无需执行任何操作。看the examples provided :

The Bootstrap 3 grid system has four tiers of classes: xs (phones), sm (tablets), md (desktops), and lg (larger desktops). You can use nearly any combination of these classes to create more dynamic and flexible layouts.

Each tier of classes scales up, meaning if you plan on setting the same widths for xs and sm, you only need to specify xs.

因此,对于桌面上的 4 列(堆叠在其他地方),只需在重复的 div 上使用 .col-md-3,摆脱 .col -xs-12.col-sm-3.

注意:我强烈建议不要将您自己的演示 CSS 类添加到您的列中。保持网格完全独立并在其中添加额外的标记以实现相同的目的:您将让自己的生活变得更加简单。

关于css - Bootstrap : Force columns to stack up vertically on mobile (responsive design),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29825427/

相关文章:

css - 如何为样式表中的文本输入设置 css 字体大小

css - 最后一个子边框不显示

html - 合并不同元素的 div

jquery - 如何阻止点击事件创建多个元素?

php - 在图标中获取数字

css - 使用 CSS 创建座位表

jquery - 所有子元素发生变化,只希望父元素被点击的div子元素发生变化。

html - cakephp:从 Bootstrap 中的标题标记中删除 html 标签

html - bootstrap "container-fluid"和 "container-full"有什么区别?

css - Flexbox 图像和文本