【发布时间】:2018-04-21 03:29:22
【问题描述】:
我正在尝试垂直对齐具有最小高度的 flexbox 容器内的一些文本,并且它运行良好,除了在 ie11 中,内容不居中。
.banner {
background:#ccc;
padding: 10px 20px;
display: flex;
align-items: center;
justify-content: center;
min-height: 60px;
flex-direction:column;
}
<div id="section-title-1" class="banner banner--theme-1 js-section-title" data-title="Section Title">
<span>IE is bobbins</span>
</div>
我环顾四周,遇到类似问题的人建议adding a height will fix the issue,但显然这否定了min-height,所以它不是很有用。
有谁知道让垂直居中在最小高度下工作的方法吗?
【问题讨论】:
-
只要让父容器成为一个弹性容器。有关详细信息,请参阅副本。 jsfiddle demo
-
我试过了,它似乎没有用,也许是行的东西破坏了它(见下面的答案之一)。如果您想回答,似乎比表格单元黑客更好的解决方案
-
在我看来,这是一种更清洁、更高效的解决方案。我将问题作为重复项关闭,因为该问题已在该帖子中详细解决。
-
您也可以使其与
flex-direction: row一起使用,但是您需要将flex-grow添加到您的内容项中。 revised demo -
啊,非常感谢 :)
标签: css internet-explorer flexbox internet-explorer-11