2017-09-04 182 views
-2

我想要一個元素在頁面中垂直居中,我使用引導4.0。我發現的大多數方法都是關於早期版本或alpha的,而官方方法不起作用,因此,有人能夠一勞永逸地解釋如何在引導中垂直居中元素嗎?在bootstrap 4.0中垂直居中元素?

+0

[Bootstrap 4中的垂直對齊]的可能重複(https://stackoverflow.com/questions/41265182/vertical-alignment-in-bootstrap-4),[引導4中的垂直對齊中心](https:// stackoverflow。 (https://stackoverflow.com/questions/9184141/how-do-tutorials/42422477),[如何使用Twitter引導獲取中心內容?](https://stackoverflow.com/questions/9184141/how-do- you-get-centered-content-using-twitter-bootstrap/42483682) – ZimSystem

+0

發佈你試過的代碼。 – ZimSystem

回答

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>