【发布时间】:2018-10-29 06:05:02
【问题描述】:
我正在尝试设置四个具有公共角落的图像面板。图片是随机挑选的,通常具有不同的尺寸。
我设法在表格的相关单元格中使用图片的绝对定位来获得正确的布局:
table {
width: 100%;
}
td {
position: relative;
}
img {
position: absolute;
}
.top img {
bottom: 0;
}
.bottom img {
top: 0;
}
.left img {
right: 0;
}
.right img {
left: 0;
}
<table>
<tr>
<td class="top left">
<img src="http://placekitten.com/200/300"/>
</td>
<td class="top right">
<img src="http://placekitten.com/300/300"/>
</td>
</tr>
<tr>
<td class="bottom left">
<img src="http://placekitten.com/300/100"/>
</td>
<td class="bottom right">
<img src="http://placekitten.com/200/200"/>
</td>
</tr>
</table>
但是,tds 由于绝对定位,其高度为零。结果,我很难将整个表格放在整个页面内的正确位置。
我想知道是否有其他方法可以实现这种布局?
【问题讨论】:
标签: html css image html-table