【发布时间】:2016-12-08 23:19:05
【问题描述】:
我正在尝试在 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>
它在 Chrome 和 Firefox 中有效,但在 IE Edge 中无效。 See Bootply here。我错过了什么?
【问题讨论】:
标签: html css twitter-bootstrap flexbox