我需要容器宽度最小高度来保存可变大小的内容,但同时我需要内容在父容器内垂直对齐。
JS 小提琴:http: //jsfiddle.net/mr_goodcat/n5Pq3/6/
HTML:
<table class="mainLayout">
<tr>
<td>
<div class="contentLayout">
<div class="tbl">
<div class="tcell">
<div class="inner">
CONTENT
</div>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td>
BOTTOM
</td>
</tr>
</table>
CSS:
body, html {
background-color: lightgreen;
height: 100%;
width: 100%;
}
.mainLayout {
height: 100%;
width: 100%;
}
.contentLayout {
width: 100%;
min-height: 200px;
border: 1px solid red;
display: block;
}
.tbl {
height: 100%;
width: 100%;
display: table;
}
.tcell {
width: 100%;
height: 100%;
background: purple;
display: table-cell;
text-align: center;
vertical-align: middle;
}
.inner {
display: inline-block;
}
想要在红色正方形(最小高度容器)内对齐紫色框。我怎么做?