【发布时间】:2017-09-28 05:09:26
【问题描述】:
我在让表格填充浮动元素中的剩余空间时遇到了一些麻烦。这就是我想要实现的目标:
这就是我目前所拥有的:
HTML:
<div class="parent">
<div class="left">
</div>
<div class="right">
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
</table>
</div>
</div>
CSS:
.parent {
height: auto;
overflow: hidden;
}
.left {
width: 125px;
background: blue;
float: left;
height: 100px;
}
.right {
background: red;
height: 100px;
}
table {
background: green;
/*width: 100%;*/
}
我尝试了width: 100%,但这并没有考虑到左浮动元素,并且表格隐藏在容器之外。我也尝试过display: block,但这会导致<td> 不再像在桌子内那样发挥作用。
【问题讨论】:
标签: html css html-table css-float