【发布时间】:2015-12-26 23:24:15
【问题描述】:
条件:
1) 所有元素应垂直居中对齐(在同一行);
2) Marginal 元素(红色)应该类似于“inline-blocks”[=][=],自动调整大小,未定义大小!
3) Central(绿色)元素应占据所有剩余位置,将元素垂直和水平居中对齐。
4) 我需要支持IE 9,所以no flex...
这是我的代码使用 FLEX,我也看到右边的页边距溢出了......
html, body {
width:100%;
}
.container {
display: table-row;
background: yellow;
width: 100%;
}
.first, .last, .center {
display: table-cell;
vertical-align: middle;
text-align: center;
background: red;
}
.first>div {display: flex;}
.last>div {display: flex;}
.center {
background: green;
width: 100%;
}
<div class="cotnainer">
<div class="first">
<div>
<img src="http://dummyimage.com/32x40" alt="">
<div>image 40</div>
</div>
</div>
<div class="center">
<div>
<img src="http://dummyimage.com/16x16" alt="">
<img src="http://dummyimage.com/16x16" alt="">
<img src="http://dummyimage.com/16x16" alt="">
</div>
</div>
<div class="last">
<div>
<div>image 50</div>
<img src="http://dummyimage.com/38x50" alt="">
</div>
</div>
</div>
如何消除 flex 并尊重正文右侧默认边距(填充)?
【问题讨论】:
标签: css