html - 电子邮件 HTML 边框覆盖内容,而不是单元格?
问题描述
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="border:2px solid #ffffff; padding: 8px 10px; border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; text-decoration:none;">
<h3 style="color:#FFFFFF;font-family:Arial, Helvetica, sans-serif;font-size:16px;font-style:normal;font-weight:bold;line-height:150%;letter-spacing:2px;text-decoration:none;text-align:center;">
<a alias="" conversion="false" data-linkto="https://" href="google.com" style="color:#ffffff;text-decoration:none; " title="Book Appointment">
<span>BOOK AN APPOINTMENT<br>
TO VISIT US TOMORROW</span></a>
</h3>
</td>
</tr>
</table>
无论我在哪里添加边框样式,它总是包裹整个单元格,而不是单元格内容本身。
代码如下:
如果我将它添加到 span 元素上,它会完全破坏边框,如下所示:
这就是我需要的样子:
我在这里做错了什么?
解决方案
这相当简单,并且将在所有电子邮件客户端中始终如一地工作。
单行文字:
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="" style="margin: auto;">
<tr>
<td style="text-align: center;">
<h3 style="margin: 0;"><a href="#" style="border: 2px solid #ffffff; font-family: sans-serif; font-weight: bold; font-size: 16px; line-height: 22px; text-decoration: none; padding: 20px 30px; color: #ff0000; display: block; letter-spacing: 2px;">Book An Appointment<br />To Visit Us Tomorrow</a></h3>
</td>
</tr>
</table>
两行文字:
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="260" style="margin: 0; border: 2px solid #ff0000;">
<tr>
<td style="background: #222222; border: 8px solid #222222; text-align: center;">
<div style="padding: 10px 15px;">
<a href="#" style="background: #222222; border: 1px solid #222222; font-family: sans-serif; font-weight: bold; font-size: 16px; line-height: 22px; text-decoration: none; color: #ffffff; display: block; letter-spacing: 2px; mso-line-height-alt: 22px;">Book An Appointment To Visit Us Tomorrow</a>
</div>
</td>
</tr>
</table>
除非您需要<h3>
屏幕阅读器,否则我建议将其删除。
祝你好运。
推荐阅读
- django - 组对象在我的详细视图中不起作用
- react-native - React Native SVG 被切断
- java - 我想在 Duo Admin API 上创建一个用户,但我不知道我做错了什么。谁能指导我?
- python - 如何使用左连接加入 2 个熊猫数据框?
- java - VertX EventBus 通道上有多少消费者?
- sql - 与“今天”日期相比,设置特定日期的 SQL 代码
- reactjs - 如何在 MobX 状态更改时重新渲染组件
- java - 我想在生物特征认证成功后去一个新的布局
- python - 如何根据复选框 [python,KivyMD] 的状态删除小部件和数据库记录
- php - Lumen 500 Internal Server Error when using any route (windows)