在表格电子邮件中。我正在寻找单元格列的动态高度宽度图像,未知高度由行跨度中的内容动态定义:
* {padding: 0;}
table { border-collapse: collapse; }
img {width: 100%; height: 100%; display: block; }
<table width="300">
<tr>
<td colspan="3" height="20" width="100%"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=" /></td>
</tr>
<tr>
<td width="20" height="20">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=" />
</td>
<td rowspan="2" width="260" align="top">
my content dynamic<br />
my content dynamic<br />
my content dynamic<br />
my content dynamic<br />
my content dynamic<br />
my content dynamic
</td>
<td width="20" height="20">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=" />
</td>
</tr>
<tr>
<td width="20" height="100%">
<img src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8zxDxHwAFtQJYX0yrrAAAAABJRU5ErkJggg==" />
</td>
<td width="20" height="100%">
<img src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8zxDxHwAFtQJYX0yrrAAAAABJRU5ErkJggg==" />
</td>
</tr>
</table>
在我的示例中,这是我想要的高度为100%的2条粉色列。它是用于电子邮件的,因此我不能使用绝对位置或JS技巧(根据caniuse for email来涵盖最多的客户)
答案 0 :(得分:3)
只需为粉红色单元格设置bgColor
属性即可。
* {padding: 0;}
table { border-collapse: collapse; }
img {width: 100%; height: 100%; display: block; }
<table width="300">
<tr>
<td colspan="3" height="20" width="100%"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=" /></td>
</tr>
<tr>
<td width="20" height="20">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=" />
</td>
<td rowspan="2" width="260" align="top">
my content dynamic<br /> my content dynamic<br /> my content dynamic<br /> my content dynamic<br /> my content dynamic<br /> my content dynamic
</td>
<td width="20" height="20">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=" />
</td>
</tr>
<tr>
<td width="20" bgColor="#ff0458">
<img src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8zxDxHwAFtQJYX0yrrAAAAABJRU5ErkJggg==" />
</td>
<td width="20" bgColor="#ff0458">
<img src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8zxDxHwAFtQJYX0yrrAAAAABJRU5ErkJggg==" />
</td>
</tr>
</table>