简体   繁体   English

电子邮件新闻稿:如何使标题的行高保持一致?

[英]E-mail newsletters: how do I keep line height for headers consistent?

I have been navigating the briar patch that is e-mail newsletter design and coding. 我一直在浏览有关电子邮件通讯设计和编码的行贿补丁。 One problem keeps on coming up: the line-height of my headings is inconsistent between different e-mail clients. 一个问题不断出现:不同电子邮件客户端之间标题的行高不一致。

One set gives a lot of space to a heading, among them Gmail and iPhone: 一组标题提供了大量空间,其中包括Gmail和iPhone: Gmail中的新闻通讯

The other group, mainly Outlook, renders headings with way less leeway: 另一组,主要是Outlook,以较小的回旋余地显示标题: 在此处输入图片说明

My code is as follows: 我的代码如下:

<table width="540" cellpadding="0" cellspacing="0" border="0">
<tr>
    <td colspan="5" width="270" height="7" style="line-height: 7px;"><img src="img/shading-top-orange.gif" width="270" height="7" style="display:block;"></td>
    <td rowspan="3" width="270" height="199"><img editable width="270" height="199" style="display:block;"></td>
</tr>
<tr bgcolor="#f68b1f" >
    <td width="10" height="185"><img src="img/shading-left-large.gif" width="10" height="185" style="display:block;"></td>
    <td width="15" height="185" bgcolor="#f68b1f"></td>
    <td width="223" height="185" bgcolor="#f68b1f" align="left" valign="top"><a name="item2" style="text-decoration: none;"><h2 style="font-family: Arial, Verdana, sans-serif; font-size: 15px; color: white !important; color:white;"><singleline label="Title" repeatertitle="true" style="color: white;">Lorem ipsum</singleline></h2></a><multiline><p style="font-family: Arial, Verdana, sans-serif; font-size: 12px; color: white;">Lorem ipsum dolor sit amet</p></multiline></td>
    <td width="15" height="185" bgcolor="#f68b1f"></td>
    <td width="7" height="185"><img src="img/shading-right-small.gif" width="7" height="185" style="display: block;"></td>
</tr>
<tr>
    <td colspan="5" width="270" height="7" style="line-height: 7px;"><img src="img/shading-bottom-orange.gif" width="270" height="7" style="display:block;"></td>
</tr>

with the newletter application filling in the text as needed. newletter应用程序根据需要填写文本。

How can I code this piece in such a way that all (or most) clients render the title as in Gmail? 我该如何编写代码,以使所有(或大多数)客户端都能像在Gmail中一样呈现标题? I have tried lots of things like adding another nested table for just the heading, giving it an orange top border, etc. These fixes also influence the Gmail rendering and that's not what I want. 我已经尝试了很多方法,例如为标题添加另一个嵌套表,为其提供橙色顶部边框等。这些修复程序还影响Gmail的呈现,这不是我想要的。

As you're seeing, you don't want to rely on line-height in HTML emails because the support between clients is pretty bad and inconsistent. 如您所见,您不想依赖HTML电子邮件中的line-height ,因为客户端之间的支持非常差且不一致。 The way to go about this is to, unfortunately, just refactor your code to nest the heck out of some tables . 不幸的是,要解决这个问题的方法就是重构代码,以使某些tables嵌套。

Check out this Fiddle here , where I basically just nested another table within a td in your second tr . 在这里查看这个小提琴 ,基本上我只是在第二个trtd内嵌套了另一个table This table has an entire td who's only job is to be a specific height and create some padding above your headline: 该表有一个完整的td ,唯一要做的就是将其设置为特定的高度,并在标题上方创建一些填充:

<tr bgcolor="#f68b1f" >
    <td width="10" height="185"><img src="img/shading-left-large.gif" width="10" height="185" style="display:block;"></td>
    <td colspan="3">  
        <table> <!--the new nested table-->
            <tr>
                <td bgcolor="#f68b1f" colspan="3" height="15"></td>
            </tr>

Unfortunately it's these kinds of table-based layout hacks that you'll have to rely on in the world of HTML emails, instead of actual CSS like line-height . 不幸的是,在HTML电子邮件世界中,您将不得不依靠这些基于表的布局hack,而不是像line-height这样的实际CSS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM