在bootstrap 4.0中垂直居中元素?
问题描述:
我想要一个元素在页面中垂直居中,我使用引导4.0。我发现的大多数方法都是关于早期版本或alpha的,而官方方法不起作用,因此,有人能够一劳永逸地解释如何在引导中垂直居中元素吗?在bootstrap 4.0中垂直居中元素?
答
使用引导的align-items-center
,可以读取here
<div class="container">
<div class="row align-items-center">
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
</div>
</div>
编辑
您还可以使用引导对柔性箱新的支持垂直居中,可以读取here
<div class="d-flex align-items-center">...</div>
[Bootstrap 4中的垂直对齐]的可能重复(https://*.com/questions/41265182/vertical-alignment-in-bootstrap-4),[引导4中的垂直对齐中心](https:// *。 (https://*.com/questions/9184141/how-do-tutorials/42422477),[如何使用Twitter引导获取中心内容?](https://*.com/questions/9184141/how-do- you-get-centered-content-using-twitter-bootstrap/42483682) – ZimSystem
发布你试过的代码。 – ZimSystem