我需要我的表格在我的 div 底部对齐,我尝试将属性添加到表格的样式中:position:absolute;bottom:0px
但它根据页面而不是 div 进行了更改。我发布了完整的代码(带有 img 标签)因为我不确定其他标签的影响。
//HTML
<div>
<img src="Img/flower" style="width: 960px; height: 474px; z-index: -1; position: absolute" />
<table style="width:100%;height:120px;">
<tr>
<td style="background-color:gray">
</td>
<td style="background-color:green">
</td>
<td style="background-color:yellow">
</td>
<td style="background-color:red">
</td>
<td style="background-color:lime">
</td>
<td style="background-color:maroon">
</td>
</tr>
</table></div>
最佳答案
<div style="position: relative;">
<img src="Img/flower" style="width: 960px; height: 474px; z-index: -1; position: relative;">
<table style="width: 100%; height: 120px;">
<tbody><tr>
<td style="background-color:gray">
</td>
<td style="background-color:green">
</td>
<td style="background-color:yellow">
</td>
<td style="background-color:red">
</td>
<td style="background-color:lime">
</td>
<td style="background-color:maroon">
</td>
</tr>
</tbody></table>
</div>
关于html - 如何在div底部设置表格,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35635643/