【发布时间】:2020-05-19 03:07:58
【问题描述】:
从 Bootstrap 4.4 升级到 4.5 后,我注意到列中的卡片曾经在屏幕尺寸变小时时做出响应,现在变成堆叠(即重叠)。
这似乎与 4.5 中的 CSS 更改有关,其中 col min-width 默认为 0。 https://github.com/twbs/bootstrap/pull/30049
在此示例中,只需在 4.4.1(响应式)和 4.5(堆叠式)之间更改 CSS 引导设置即可查看效果 https://codepen.io/alonergan/pen/BaoGqwO
想问一下其他人是否注意到了这一点,这是预期的结果还是 bootstrap 4.5 中的回归?
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row mt-5">
<div class="col">
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
<div class="col">
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
<div class="col">
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
</div>
</div>
【问题讨论】:
-
这看起来是正确的行为,那么您希望卡片在屏幕尺寸减小时发生什么?
-
该示例使用了 bootstrap 4.4,它的行为正确。我将示例修改为使用 4.5,以说明卡片重叠的新行为。
-
重叠?意思是一张卡在另一张上面?我没有看到我所看到的行为只是减小它包裹的屏幕尺寸并使其成为单列
-
能否建议您刷新页面并重新运行 sn-p,以确认我在示例中从 BS 4.4 到 4.5 所做的更改是否有效?
-
感谢您的意见。我发现我的代码的一个更好的解决方案是添加/覆盖 col min-width,例如 min-width: 18rem (或者确实坚持使用旧的 BS 版本)。
标签: css bootstrap-4