gpt4 book ai didi

html - Bootstrap 文本垂直居中对齐

转载 作者:太空宇宙 更新时间:2023-11-04 09:40:57 25 4
gpt4 key购买 nike

我想让一个文本在 100vh 高度上垂直居中。这是我所做的

.about-header {
height: 100vh;
background: #000;
}
.about-header p {
font-size: 5em;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container-fluid about-header text-center">
<div class="row ">
<div class="col-md-12">
<p>Lorem Ipsum</p>
</div>
</div>
</div>

最佳答案

只需在 CSS 下方添加:-

.about-header{
height: 100vh;
background: #000;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}

您的内容将垂直对齐。

关于html - Bootstrap 文本垂直居中对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39930650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com