【发布时间】:2020-04-02 11:16:54
【问题描述】:
查看 bootstrap 4 Flex 文档后,我似乎无法让“align-item-center”属性工作。我测试了几乎所有在线可用的示例,但似乎真的无法改变任何东西的垂直对齐方式,这让我发疯了。我加入了一个我正在尝试制作的简单 HTML 示例。
.d-flex {
display: -ms-flexbox !important;
display: flex !important;
}
.justify-content-center {
-ms-flex-pack: center !important;
justify-content: center !important;
}
.align-items-center {
-ms-flex-align: center !important;
align-items: center !important;
}
<div class="d-flex justify-content-center align-items-center">
<p> This should be centered right ?</p>
</div>
我正在使用 Bootstrap 4.4.1 并且还安装了 popper.js@latest 和 jquery@latest 以确保。为了更精确,我现在只使用一个简单的文本行,但将来我会添加直到运行时才知道大小的元素。
【问题讨论】:
-
这个不以什么方式居中?
-
它已经在工作了。尝试为父 div 指定高度并查看对齐方式。
标签: html css bootstrap-4 flexbox