我试图在Bootstrap 3.3.7 using flexbox
中的一行内垂直对齐列。该行的最小高度必须为62px
。
我有三个列;一列(.title
)始终包含一些文本,另外两列有时可能是hidden or empty
。无论如何,它们应始终在行中垂直对齐。
我有这个HTML :
.titlebar {
border: 1px solid red;
font-size: 21px;
line-height: 1.2em;
min-height: 62px;
overflow: hidden;
margin-left: 0;
margin-right: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
.titlebar .title {
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
font-size: 21px;
}
.titlebar .byline {
font-size: 16px;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row titlebar">
<div class="col-sm-8 col-md-9 col-sm-offset-4 col-md-offset-3 title">Title</div>
<div class="col-sm-8 col-md-9 col-sm-offset-4 col-md-offset-3 byline"></div>
<div class="col-sm-12 visible-xs-block titlebar-gradient"></div>
</div>
</div>
&#13;
它在Chrome和Firefox中工作,但在IE Edge中没有。 See Bootply here。我错过了什么?
答案 0 :(得分:1)
好吧,似乎IE 10-11不适用于最小高度:https://philipwalton.com/articles/normalizing-cross-browser-flexbox-bugs/
将最小高度更改为高度可以解决问题。