【发布时间】:2017-11-28 02:36:39
【问题描述】:
我想要达到的目标:
-
等高的列指向子级,因此列之间的间隙可见(Codepen 中的第一个解决方案,但在 Safari (Mac) 上失败)。
或(如果可能的话)
-
等高的 Bootstrap 列之间有可见的间隙(如果我将背景颜色设置为
李>col类 div - 由于填充,间隙不可见 - 您可以在 Codepen 中看到)。
我尝试过的:
- 将
h-100类 (height: 100%) 设置为直接子列,但在 Safari (see StackOverflow question) 上失败。 - 在
coldiv 上使用水平margins而不是padding,但这会破坏Bootstrap 的网格系统。
CODEPEN
HTML:
<div class="container">
<h3>This is how it should work - fails on Safari (Mac)</h3>
<div class="row">
<div class="col-4">
<div class="inner h-100">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
</div>
<div class="col-4">
<div class="inner h-100">Inner</div>
</div>
<div class="col-4">
<div class="inner h-100">Inner</div>
</div>
<div class="col-4">
<div class="inner h-100">Inner</div>
</div>
<div class="col-4">
<div class="inner h-100">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
</div>
</div>
</div>
<div class="container">
<h3>Backgrounds applied to col divs (gaps are not visible because of cols padding)</h3>
<div class="row no-gutters">
<div class="col-4 bg">
<div class="inner">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
</div>
<div class="col-4 bg">
<div class="inner">Inner</div>
</div>
<div class="col-4 bg">
<div class="inner">Inner</div>
</div>
<div class="col-4 bg">
<div class="inner">Inner</div>
</div>
<div class="col-4 bg">
<div class="inner">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
</div>
</div>
</div>
<div class="container">
<h3>Basic Bootstrap HTML</h3>
<div class="row">
<div class="col-4">
<div class="inner">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
</div>
<div class="col-4">
<div class="inner">Inner</div>
</div>
<div class="col-4">
<div class="inner">Inner</div>
</div>
<div class="col-4">
<div class="inner">Inner</div>
</div>
<div class="col-4">
<div class="inner">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
</div>
</div>
</div>
CSS:
.inner,
.bg {
background: #ddd;
}
.h-100 {
height: 100%;
}
【问题讨论】:
-
您使用的是哪个版本的 Safari?你的 codepen 在我的看起来不错(版本 11.0 (11604.1.38.1.7))
-
嗯,我现在无法访问我的 Mac,明天我会检查它。
-
我也很好。你可以试试
min-height:100% -
它可能在 11 中修复,我有 Safari 10.1,但它不起作用。我找到了另一个解决方案,但我会等几个小时才能得到答案;)
标签: html twitter-bootstrap css flexbox