html 电子邮件的 100% 表格宽度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22819973/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:27:42  来源:igfitidea点击:

100% table width for html email

htmlcssemailmailchimp

提问by user3380148

I am building an HTML email campaign using Mailchimp and my own HTML. I have heard that to build a successful HTML email you must focus on using tables, and use inline CSS. I have removed all padding from my styles and added in 0 measure to margin, padding, border and outline tags. Any suggestions guys? Really stuck with this.

我正在使用 Mailchimp 和我自己的 HTML 构建 HTML 电子邮件活动。我听说要构建成功的 HTML 电子邮件,您必须专注于使用表格,并使用内联 CSS。我已经从我的样式中删除了所有填充,并以 0 度量添加到边距、填充、边框和轮廓标签。有什么建议吗?真的坚持这一点。

<body style="background:blue; margin:0; padding:0; border:0; outline:0;">

<div id="wrap" style="background:green; width:100%;">

<table width="100%">
<tr>
  <td style="
      width:100%; margin:0; padding:0; border:0; outline:0;
      height:100px;
      background:#4b86fc;
      background-size:60px 60px;
      ">
    </td>
  </tr>
</table>

<table width="500" align="center">
<tr>
  <td style="
      padding:20px 0px 25px 0px;
      color:#000; font-family:Verdana, Geneva, sans-serif;
      font-weight:100; font-size:12px;">
      <p>Hi,</p>
<p>Lorem ipsum dolor sit amet.</p>
<p>Many Thanks, 
Liam</p></td>
  </tr>
</table>

<table width="100%">
<tr>
  <td style="
      width:100%; margin:0; padding:0; border:0; outline:0;
      background-color:#ebebeb;
      background:#ebebeb;
      border-top:1px solid #c3c3c3;
      font-family:Verdana, Geneva, sans-serif;
      font-weight:100; font-size:11px;
      text-align:center;">
        <ul style="list-style-type:none; margin:0; padding:0;">
        <li style="display:inline; padding:0 8px 0 0;"><a href="" style="text-decoration: none;     color:#545454;">Homepage</a></li>
        <li style="display:inline; padding:0 8px 0 0;"><a href="" style="text-decoration: none;     color:#545454;">Twitter</a></li>
        <li style="display:inline; padding:0 8px 0 0;"><a href="" style="text-decoration: none;     color:#545454;">Dribbble</a></li>
        <li style="display:inline; padding:0 0 0 8px;"><a href="" style="text-decoration: none;     color:#545454;">Facebook</a></li>
</ul>

</td>
</tr>
</table>

</div>

</body>

回答by John

This will get you started:

这将使您开始:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title></title>
  <style type="text/css">
    #outlook a {padding:0;}
    body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0;} /* force default font sizes */
    .ExternalClass {width:100%;} .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;} /* Hotmail */
    a:active, a:visited, a[href^="tel"], a[href^="sms"] { text-decoration: none; color: #000001 !important; pointer-events: auto; cursor: default;}
    table td {border-collapse: collapse;}
  </style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="margin: 0px; padding: 0px; background-color: #FFFFFF;" bgcolor="#FFFFFF"><table bgcolor="#252525" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td><table width="600" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td valign="top" style="padding-top:30px; padding-bottom:30px;">

<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td>
     content
    </td>
  </tr>
</table>

</td></tr></table></td></tr></table></body></html>

This has the background set as white (#FFFFFF) so that if someone forwards it, they will be writing on white. You can change this to whatever, just keep in mind nobody wants to type on a dark color. The inner table (on the same line as the <body>tag) controls color of the html area background color (#252525). The content table is your center floated panel.

这将背景设置为白色(#FFFFFF),以便如果有人转发它,他们将在白色上书写。您可以将其更改为任何内容,但请记住,没有人想输入深色。内表(与<body>标签在同一行)控制 html 区域背景颜色的颜色 (#252525)。内容表是您的中心浮动面板。

See this threadfor a lot more info on html email.

有关html 电子邮件的更多信息,请参阅此线程

回答by Jeggs

Have you had a look at html email boilerplate

你有没有看过html电子邮件样板

Excellent template for... HTML Email!

优秀模板... HTML 电子邮件!

I know this is not a direct answer to the problem, but I can't post comments yet, sorry.

我知道这不是问题的直接答案,但我还不能发表评论,抱歉。

回答by mareoraft

By default, most browsers add margin to the BODYtag. Therefore you need

默认情况下,大多数浏览器都会为BODY标签添加边距。因此你需要

<body style="background:blue;margin:0">

to get rid of that margin.

摆脱那个边缘。

回答by Bijeesh E K


You can apply 100% width for table in html email


您可以在 html 电子邮件中为表格应用 100% 宽度

Also consider these things :

还要考虑这些事情:

1 - Must include <meta http-equiv="Content-Type" content="text/html charset=UTF-8" />in <head>.

1 - 必须包含<meta http-equiv="Content-Type" content="text/html charset=UTF-8" /><head>.

2 - Apply mso-line-height-rule: exactly;at the <body>. Like, <body mso-line-height-rule:exactly;>

2 -mso-line-height-rule: exactly;<body>. 喜欢,<body mso-line-height-rule:exactly;>

3 - Please avoid <ul>& <li>tags, you can use <p>or any other supporting tags. Use &bull;for bullet.

3 - 请避免使用<ul>&<li>标签,您可以使用<p>或任何其他支持标签。使用&bull;的子弹。

4 - Use <table>instead of <div>

4 - 使用<table>代替<div>

5 - Use <b>instead of <strong>.

5 - 使用<b>代替<strong>

6 - Use nested tables, rather than rowspanor colspan.

6 - 使用嵌套表,而不是rowspancolspan

Go to https://www.campaignmonitor.com/css/for all kind of help in css for mailer

转到https://www.campaignmonitor.com/css/获取有关邮件程序 css 的所有帮助

回答by peridot1986

Have you tried putting

你试过把

margin:0;

in the body style tag?

在体型标签中?