简体   繁体   English

HTML电子邮件中的嵌入式边框样式

[英]inline border styles in an HTML Email

I'm working on a responsive HTML email and I'm having a rendering problem in Gmail ONLY in IE (just had to be!) It works fine in the other 27 client variants. 我正在处理响应HTML电子邮件,并且仅在IE中的Gmail中存在呈现问题(只是必须如此!)在其他27个客户端变体中都可以正常工作。 we need to support 我们需要支持

I've set up a fiddle here: http://jsfiddle.net/39gzj/ 我在这里设置了一个小提琴: http : //jsfiddle.net/39gzj/

Now if you look at the code, you will see that there is a border that is grey, which then contains another border that is white. 现在,如果您看一下代码,您将看到有一个灰色边框,然后包含另一个白色边框。 For some bizarre reason, Gmail in Explorer, will not show this border at all, save for the border at the bottom of the sign up bottom. 出于某种奇怪的原因,资源管理器中的Gmail根本不会显示该边框,除非是注册底部底部的边框。 I thought it was something to do with the way that I had coded the border (I'm going off someone elses code, I've only made some minor changes to this) as the border has been done as follows: 我认为这与我编写边框的方式有关(我正在关闭其他人的代码,对此只做了一些小的更改),因为边框已按以下方式完成:

border-left-style:solid;border-left-width:1px;border-left-color:#fff;

So I changed the way that the border both grey and white to be declared as follows: 因此,我更改了声明灰色和白色边框的方式,如下所示:

border-left-style: 1px solid #fff;

But this makes no difference whatsoever. 但这没有任何区别。 This is driving me insane so please help if you can. 这让我发疯,所以请帮助。 I thought it may be something to do with the widths? 我认为这可能与宽度有关吗? But having played around with this it just broke the problem in all other clients. 但是,在解决了这一问题之后,它就解决了所有其他客户的问题。 Any help would be much appreciated as I may smash my head into my computer screen soon. 任何帮助将不胜感激,因为我可能很快就会将头砸向计算机屏幕。

Appreciate that this code contains crazy inline styles but this is of course the nature of HTML emails. 赞赏此代码包含疯狂的内联样式,但这当然是HTML电子邮件的本质。

UPDATE: Removing the white inner border that is on the <td> elements renders the grey border. 更新:删除<td>元素上的白色内部边框将呈现灰色边框。 Is this something to do with me setting the widths incorrectly? 这与我错误地设置宽度有关吗?

UPDATE 2 : It's IE9 that this is being rendered incorrectly in. And ONLY for Gmail. 更新2:这是IE9呈现不正确。并且仅适用于Gmail。

Your problem is that the border is on the table itself. 您的问题是边框本身在桌子上。 You tend to find that the email clients don't like that. 您往往会发现电子邮件客户端不喜欢这样。 The way that I got around it was by placing tables within tables a bit like this: 我解决该问题的方法是将表放在表中,如下所示:

<table width="600" cellpadding="0" cellspacing="0" border="0"> 
<tr>
<td width="600" valign="top" align="center" bgcolor="#CCCCCC">
    <img src="spacer.gif" width="1px" height="1px" style="border:0px; display:block;">
    <table width="598" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
    <tr>
    <td width="598" align="left">
    Text Here
    </td>
    </tr>
    </table>
    <img src="spacer.gif" width="1px" height="1px" style="border:0px; display:block;">
</td>
</tr>
</table>
    <br/><br/><br/>
<table width="600" cellpadding="0" cellspacing="1" border="0" bgcolor="#CCCCCC"> 
<tr>
<td width="600" valign="top" align="left" bgcolor="#FFFFFF">
    Text Here
</td>
</tr>
</table>

Here is the code on a: jsfiddle I have created 2 different ways to get a similar effect. 这是一个代码: jsfiddle我创建了2种不同的方法来获得类似的效果。 You can choose the one that works best for yourself. 您可以选择最适合自己的一种。

I also see that you have used max-width which some email clients dont like so that might be your problem. 我还看到您使用了某些电子邮件客户端不喜欢的max-width,这可能是您的问题。 here is the campaignmonitor guide to css classes and what you should and should not use: http://www.campaignmonitor.com/css/ 这是CampaignMonitor的CSS类指南,以及您应该使用和不应该使用的指南: http : //www.campaignmonitor.com/css/

I use the following on a table in my email and have no issues. 我在电子邮件中的表格上使用了以下内容,没有任何问题。

border-left: 2px #000000 solid;border-right: 2px #000000 solid;

I've tested in multiple browsers & email clients. 我已经在多种浏览器和电子邮件客户端中进行了测试。 Make sure your styles are inline, make sure you haven't got a differing border on any outer tables, as Outlook etc. seem to inherit from the parent TD 确保样式是内联的,确保外部表没有边框,因为Outlook等似乎继承自父TD

The problem I had with IE9 and Gmail which stood out to me was that it rendered the responsive version of my email, so check your media queries. 我对IE9和Gmail表现出的突出问题是,它呈现了电子邮件的响应版本,因此请检查您的媒体查询。 The way to solve this is to add CSS so if you have <td width="600"> you need to make sure it becomes <td width="600" style="width:600px;"> 解决此问题的方法是添加CSS,因此如果您<td width="600"> ,则需要确保它变为<td width="600" style="width:600px;">

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

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