首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >引导4列浮动风格像引导3是可能的吗?

引导4列浮动风格像引导3是可能的吗?
EN

Stack Overflow用户
提问于 2017-04-07 19:27:03
回答 1查看 6.9K关注 0票数 1

我从引导4开始开发,现在我发现了这个问题:当使用引导3列系统时,因为它使用浮点数,我们可以在一行中插入多个列,它会根据指定的“col”填充空格,如下所示:

http://codepen.io/seltix/pen/QpXvRJ

代码语言:javascript
复制
 -------   -------   -------
| COL 1 | | COL 2 | | COL 3 |
|       |  -------   -------
|       | | COL 4 | | COL 5 |
 -------   -------   -------

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-6 panel height-1">
      <div class="bg-danger">this box is a slider with fixed col-6 width and fixes 2 blue boxes height</div>
    </div>
    <div class="col-sm-3 panel height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
    <div class="col-sm-3 panel height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
    <div class="col-sm-3 panel height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
    <div class="col-sm-3 panel height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
    <div class="col-sm-3 panel height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
</div>

但是,对于引导4 flex系统,每个元素使用行的全部高度,结果如下:

http://codepen.io/seltix/pen/PprmVE

代码语言:javascript
复制
 -------   -------   -------
| COL 1 | | COL 2 | | COL 3 |
|       |  -------   -------
|       |
 -------   -------
| COL 4 | | COL 5 |
 -------   -------

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-6 card height-1">
      <div class="bg-danger">this box is a slider with fixed col-6 width and fixes 2 blue boxes height</div>
    </div>
    <div class="col-sm-3 card height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
    <div class="col-sm-3 card height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
    <div class="col-sm-3 card height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
    <div class="col-sm-3 card height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
    <div class="col-sm-3 card height-2">
      <div class="bg-info">blue boxes count may change depending on the content.<br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
    </div>
</div>

我已经谷歌它和搜索引导4文档,但我找不到任何解决方案。最接近的是卡片列,一个类似砖石的例子,但我认为它不适合这个例子,因为我不能指定列/卡片的宽度。谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-08 11:29:35

是的,您可以使用实用工具类在Bootstrap 4中获得3.x网格“浮动”行为。

使用d-block将display:flex中的行更改为display:block。然后在每个项目上使用float-left

http://www.codeply.com/go/BmN6ZYQdGm

代码语言:javascript
复制
 <div class="row d-block">
        <div class="col-md-6 float-left card height-1">
            <div class="bg-danger">1
                <br>this box is a slider with fixed col-6 width and fixes 2 blue boxes height</div>
        </div>
        <div class="col-md-3 float-left card height-2">
            <div class="bg-info">2
                <br>blue boxes count may change depending on the content.
                <br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
        </div>
        <div class="col-md-3 float-left card height-2">
            <div class="bg-info">3
                <br>blue boxes count may change depending on the content.
                <br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
        </div>
        <div class="col-md-3 float-left card height-2">
            <div class="bg-info">4
                <br>blue boxes count may change depending on the content.
                <br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
        </div>
        <div class="col-md-3 float-left card height-2">
            <div class="bg-info">5
                <br>blue boxes count may change depending on the content.
                <br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
        </div>
        <div class="col-md-3 float-left card height-2">
            <div class="bg-info">6
                <br>blue boxes count may change depending on the content.
                <br>if there are only 1 blue box the col size will change from 3 to 6 in the PHP</div>
        </div>
    </div>

http://www.codeply.com/go/BmN6ZYQdGm

相关:Bootstrap 4 - I don't want columns to have the same height

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43285745

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档