【发布时间】:2017-09-03 06:55:07
【问题描述】:
我开始使用 bootstrap 4 进行开发,现在我发现了这个问题: 当使用 bootstrap 3 列系统时,因为它使用浮点数,我们可以在一行中插入多列,它会根据指定的“col-size”填充空间,如下所示:
http://codepen.io/seltix/pen/QpXvRJ
------- ------- -------
| 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>
但是使用 bootstrap 4 flex 系统,每个元素都使用行的全高,结果是这样的:
http://codepen.io/seltix/pen/PprmVE
------- ------- -------
| 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>
我已经用谷歌搜索并在 bootstrap 4 文档中搜索,但我没有找到任何解决方案。我发现最接近的是卡片列,一个类似砖石的例子,但我认为它不适用于这个例子,因为我无法指定列/卡片的宽度。 谢谢!
【问题讨论】:
标签: css-float multiple-columns bootstrap-4 dynamic-columns