【问题标题】:Force html email in Thunderbird to float elements within container强制 Thunderbird 中的 html 电子邮件在容器中浮动元素
【发布时间】:2013-12-18 06:50:48
【问题描述】:

我有一个问题,Thunderbird 没有根据父宽度清除内表。

上图显示了它的外观,下图显示了它在 Thunderbird 中的外观。

<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td valign="top"> 

        <table cellpadding="0" cellspacing="0" border="0" align="center" style="max-width: 600px; width: 100%; table-layout: fixed; background:  red;">
            <tr>
                <td valign="top">

            <table cellpadding="0" cellspacing="0" border="0" align="left" style="width: 100px; table-layout: fixed; background:  blue;">
                    <tr>
                <td>test</td>
              </tr>
            </table>

          <table cellpadding="0" cellspacing="0" border="0" align="left" style="width: 100px; table-layout: fixed; background:  blue;">
                    <tr>
                <td>test</td>
              </tr>
            </table>
          <table cellpadding="0" cellspacing="0" border="0" align="left" style="width: 100px; table-layout: fixed; background:  blue;">
                    <tr>
                <td>test</td>
              </tr>
            </table>
          <table cellpadding="0" cellspacing="0" border="0" align="left" style="width: 100px; table-layout: fixed; background:  blue;">
                    <tr>
                <td>test</td>
              </tr>
            </table>
          <table cellpadding="0" cellspacing="0" border="0" align="left" style="width: 100px; table-layout: fixed; background:  blue;">
                    <tr>
                <td>test</td>
              </tr>
            </table>
          <table cellpadding="0" cellspacing="0" border="0" align="left" style="width: 100px; table-layout: fixed; background:  blue;">
                    <tr>
                <td>test</td>
              </tr>
            </table>
          <table cellpadding="0" cellspacing="0" border="0" align="left" style="width: 100px; table-layout: fixed; background:  blue;">
                    <tr>
                <td>test</td>
              </tr>
            </table>
          <table cellpadding="0" cellspacing="0" border="0" align="left" style="width: 100px; table-layout: fixed; background:  blue;">
                    <tr>
                <td>test</td>
              </tr>
            </table>
          <table cellpadding="0" cellspacing="0" border="0" align="left" style="width: 100px; table-layout: fixed; background:  blue;">
                    <tr>
                <td>test</td>
              </tr>
            </table>


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

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

如果我将内部表格更改为非常长的段落,则文本会按预期换行。我需要将表格简单地浮动在彼此旁边,以便它在不支持媒体查询的 Outlook 或手机中工作。

这个实时示例显示它在 Firefox 中正常工作:http://codepen.io/anon/pen/ioBdw

【问题讨论】:

    标签: html css email html-email thunderbird


    【解决方案1】:

    这是做到这一点的怪癖模式。在 quirks 模式下,两个相邻的浮动表不会换行到下一行。您可以通过从页面中删除 DOCTYPE 声明来签入 Firefox;那么它的行为将与 Thunderbird 相同。

    所以...要么找到一种在标准合规模式下发送电子邮件的方法,要么确保您没有浮动表格。

    实现后者的一种方法是将每个内部表包装在一个浮动的 div 中。浮动 div 是可以的,即使浮动表格不是(不要问为什么;这是怪癖模式)。

    <div style="float:left" align="left">
     <table cellpadding="0" cellspacing="0" border="0" style="width: 100px; table-layout: fixed; background: lime;" align="left">
      <tr>
       <td>test</td>
      </tr>
     </table>
    </div>
    

    (并根据需要重复多次)

    【讨论】:

    • 刚刚在putsmail.com 上进行了一些测试,我在想为什么它在那里不起作用。虽然他们正在做一些时髦的事情。谢谢大家现在工作正常。
    • 我在 Outlook 中添加了width: auto; 表所需的一些编辑。 align="left"div 上也是必需的,因为如果没有它,它在 Outlook 中的行为会很奇怪。
    【解决方案2】:

    我知道您具体询问的是 Thunderbird,但我假设您要发送给多个客户。

    在 Outlook 中根本不支持 CSS 浮动,因此很遗憾,您一直使用的 align="left" 是主要客户支持在 html 电子邮件中“浮动”的唯一方法。

    尝试将align="left" 添加到您的父表&lt;td&gt;。此外,为了使 align 起作用,您可能必须在 html width="600" 中设置宽度(例如)。

    此外,Outlook 不支持最大宽度,您应该始终在 html 电子邮件中使用 6 位十六进制颜色声明。

    【讨论】:

    • 谢谢,为了绕过 Outlook,我使用 &lt;!--[if mso]&gt; 并插入一个固定宽度的表格
    • @JohnMagnolia 这可以作为 Outlook 的后备。为什么不在 Outlook 中尝试get it actually working
    猜你喜欢
    • 2017-09-21
    • 2016-03-25
    • 1970-01-01
    • 2013-11-23
    • 2016-05-17
    • 2018-01-18
    • 1970-01-01
    • 1970-01-01
    • 2013-02-28
    相关资源
    最近更新 更多