我有一個(gè)非常簡單的片段:
.parent {
display: flex;
background-color: blue;
}
.child100 {
width: 6px;
height: calc(100% - 5px);
background-color: red;
}
<body>
<div class="parent">
<div class="child100"></div>
<div class="childContent">
<table>
<tr>
<th>
1
</th>
<th>
2
</th>
</tr>
<tr>
<th>
3
</th>
<th>
4
</th>
</tr>
</table>
</div>
</div>
</body>
刪除高度定義并添加底部邊距。flexbox的拉伸對(duì)齊將為您完成這項(xiàng)工作。
.parent {
display: flex;
background-color: lightblue;
}
.child100 {
width: 6px;
margin-bottom: 5px;
background-color: red;
}
<body>
<div class="parent">
<div class="child100"></div>
<div class="childContent">
<table>
<tr>
<th>
1
</th>
<th>
2
</th>
</tr>
<tr>
<th>
3
</th>
<th>
4
</th>
</tr>
</table>
</div>
</div>
</body>