我有以下代碼:http://jsfiddle.net/GUSE5/5/防止HTML表格
我想的是,每行有身高表高度的33%,無論內容和圖像尺寸調整到適合細胞,但沒有失去比例。
<table class="container"><tr><td>
<table class="contents" border=1>
<tr>
<td>
Top content
</td>
</tr>
<tr>
<td>
<img src="http://www.hdwallpapersview.com/wp-content/uploads/2013/05/free-nature-backgrounds-wallpapers.jpg" />
</td>
</tr>
<tr>
<td>
Bottom content
</td>
</tr>
</table>
</td></tr></table>
CSS:
table.container {
width: 200px;
height: 300px;
}
table.contents {
width: 100%;
height: 100%;
}
table.contents tr {
height: 33%;
}
img {
max-width: 100%;
max-height: 100%;
}
您可能需要考慮一下版權問題 –
圖像僅僅是一個例子。我在我的程序中使用不同的圖像。 – Vlad