【发布时间】:2012-01-28 19:05:06
【问题描述】:
我正在处理 HTML 电子邮件并尝试将绿色 TD 居中放置在白色 TR 中,以便在绿色框的左侧和右侧有 20 像素的白色边距。
我尝试为绿色部分设置 TD 宽度并将边距设置为 0 自动,但绿色只是扩展到 TR 的宽度。
尝试再放入 2 个 TD 以将绿色 TD 推到中心,但也没有用。
包括代码 sn-p,我在使用带有 #a6d971 的 TR 时遇到问题。
<table cellspacing="0" cellpadding="0" border="0" width="600" height="" bgcolor="" style="margin: 0 auto;">
<tbody>
<tr>
<td style="margin: 0 auto;">
<img width="600" height="23" padding="0" src="assets/graphic_scalloped_top.png" alt="" style="display: block;" />
</td>
</tr>
<tr bgcolor="#fff" height="75">
<td valign="top" style="text-align:center;">
<p style="margin:0; padding-bottom: 3px; padding-top: 3px; color:#545d69; font-size: 24px; text-align:center; font-family: Arial, Helvetica;">
Regular sales happen every day
</p>
<p style="margin:0; padding-bottom: 3px; padding-top: 3px; color:#4bc1d6; font-size: 16px; text-align:center; font-family: Arial, Helvetica;">
9am - 11pm
</p>
</td>
</tr>
<tr bgcolor="#fff" height="75" padding="10">
<td bgcolor="#000" width="20"></td>
<td bgcolor="#a6d971" width="300" style="margin: 10;">
</td>
<td bgcolor="#000" width="20"></td>
</tr>
<tr bgcolor="#fff">
<td valign="top">
<table cellspacing="0" cellpadding="10" border="0" align="center" width="100%" bgcolor="#fff" style="">
<tbody>
<tr>
<td height="80" style="font-family: Helvetica, Arial, sans-serif; font-size: 18px; font-weight: bold; color: #555; background:url('assets/graphic_9am.png') no-repeat; background-position: 10% center; padding:10px; margin:0;">
<h3>Nine @ Nine</h3>
<p>Fuel up! Dresses, tunics and other items including:</p>
</td>
</tr>
<tr>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="margin: 0 auto;">
<img width="600" height="23" padding="0" src="assets/graphic_scalloped_bottom.png" alt="" style="display: block;" />
</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
对于电子邮件客户端在使用 CSS 时遇到的所有问题……当您想要做的只是将一个框居中并设置一些颜色时,它们通常非常好。不要为此滥用表格。
-
你有图片说明吗?
-
您使用表格有什么特别的原因吗?
-
@Purmou,尽管让我很痛苦,但表格和内联 CSS 仍然是电子邮件开发的最佳方式。 =/
-
是的,这就是我必须使用表格的原因:\
标签: html html-table alignment