html - Bootstrap 将 div 内容推送到新行

标签 html css twitter-bootstrap

不知何故,我不知道如何完成我格式化为列表的代码,还需要将其格式化为由 javascript 切换的网格。

我下面的 HTML 代码用于列出一个内容:

<div class="list">
    <div class="row">
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">Right is next DIV</div>
        <div class="col-lg-6 col-md-6 col-sm-5 col-xs-12">Right is next DIV</div>
        <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">I am the last DIV</div>
    </div>
</div>

列表的 CSS 代码。所有其他 CSS 都由 Bootstrap 获取:

.styled_view div.list {
    padding: 0;
    width: 100%;
}

应该使用相同的代码来显示网格:

<div class="grid">
    <div class="row">
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">Under me should be a DIV</div>
        <div class="col-lg-6 col-md-6 col-sm-5 col-xs-12">Under me should be a DIV</div>
        <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">I am the last DIV</div>
    </div>
</div>

网格的 CSS:

.styled_view div.grid {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
    width: 19.4%;
}

画廊每个部分的 19.4% 使 DIV 紧挨着。它不会将其推到新行。我该如何解决?

最佳答案

做一个行 div。

像这样:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<div class="grid">
    <div class="row">
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12 bg-success">Under me should be a DIV</div>
        <div class="col-lg-6 col-md-6 col-sm-5 col-xs-12 bg-danger">Under me should be a DIV</div>
    </div>
    <div class="row">
        <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12 bg-warning">I am the last DIV</div>
    </div>
</div>

关于html - Bootstrap 将 div 内容推送到新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22943270/

相关文章:

html - 有没有办法在不导致网站在平板电脑上放大的情况下为手机设置最小视口(viewport)大小?

HTML/CSS : Div not expanding to height of content

css - Bootstrap Tooltip 默认样式不对?

javascript - 如何在 JavaScript 中将日期增加一个月?接收未捕获的类型错误

javascript - Highcharts - 在向下钻取项上正确切换表格

javascript - 如何永久更改 CSS 文件,以便将更改保存在服务器上的实际文件中?

css - 具有背景颜色的行的顶部间距

html - Bootstrap 导航栏不尊重文本颜色

html - 在没有系统字体的环境中测试网页

javascript - 是否有另一种模拟对象拟合的方法 :fill on a video element so that all major browsers recognize it?