有什么办法可以使它们全部.col
与顶部对齐,使其兄弟姐妹的高度与上方对齐?
这是我目前用于保持高度和宽度相等的解决方案。
<div class="row">
<div class="col">...</div>
<div class="col">...</div>
</div>
.row {
display: flex; /* assigns equal height to all the children */
}
.col {
flex: 1; /* assigns, equal width*/
}
这是向后支持IE8,9等浏览器的解决方案:
.row {
display: table;
}
.col {
display: table-cell;
width: 50%; /* depends on the number of columns, 50% for two col, 25% for four column and so on*/
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句