【发布时间】:2021-05-29 01:15:19
【问题描述】:
所以 - 是的,这又是某种垂直对齐的东西(对不起!)。我阅读了有关该主题的文档和其他问题,完成了我的第一个项目并尝试了不同的方法,但不知何故,我无法弄清楚如何使用 bootrap 以“正确的方式”做到这一点。
我希望列内的元素与另一列中的相应元素在同一水平线上(从顶部开始)对齐。因此,h3 元素都在同一条线上水平线,按钮都在同一条线上等等。
我做了3列
<div class="container">
<div class="row justify-content-around>
<div class="col-md-4 d-flex flex-column align-items-center">
<h3> A Title </h3>
<hr>
<p> looooong text </p> <br>
<img src="an icon" width="55" height="55">
<button> A button </button>
</div>
<div class="col-md-4 d-flex flex-column align-items-center">
<h3> A Title </h3>
<hr>
<p> looooong text </p> <br>
<img src="an icon" width="55" height="55">
<button> A button </button>
</div>
<div class="col-md-4 d-flex flex-column align-items-center">
<h3> A Title </h3>
<hr>
<p> Short text </p> <br>
<img src="an icon" width="55" height="55">
<button> A button </button>
</div>
</div>
</div>
我可以在每一列上使用“justify-content-between”。但是,如果其中一个“p”内容比另一列的内容长,它将无法按预期工作 - 较短的文本不会与其他文本在同一水平线上开始,如下面的示例所示.如果客户端稍后更改文本,使用手动边距修复它会搞砸。
Justify-Content-Between: This is what I don't want
什么是实现这种对齐的好方法?
【问题讨论】:
标签: html css twitter-bootstrap bootstrap-4 alignment