【问题标题】:html email breaks 'when using float on table' in hotmail and outlookhtml 电子邮件在 hotmail 和 Outlook 中“使用浮动表格时”中断
【发布时间】:2015-03-05 03:10:24
【问题描述】:

我有一封 HTML 电子邮件,其中包含相互浮动的“迷你表格”。

因此,我可以得到两张相对的迷你桌子;然后迷你桌子相互叠放。

它在 yahoo 电子邮件中完美运行,但在 HotmailOutlook手机/平板电脑上崩溃。

以下是它在雅虎电子邮件中的外观示例:

但这就是它在 Outlook 和 Hotmail 中的外观:

我在下面附上了我的代码

我使用动态 PHP foreach 循环从数据库中生成数据。

foreach ($this->getMembers() as $user)

{ 


<td width='310' style='float:left'>
   <TABLE width='300'  border='0' colour='#FFFFFF' bgcolor='#FFFFFF' style='margin-left: 5px;  border: 1px solid #999999; float: left; margin-top: 10px; margin-bottom: 10px'>
    <TR>

    <TH ROWSPAN=5 width='150' height='150'>
          <a href='https://www.bab.com/profile'>
             <img src='https://www.bab.com />  
          </a> 
      </TH>
       <TD width='150'  >
        {$user->getFirstName()}&nbsp;&nbsp;(Aged: {$user->getActualAge()})
       </TD> 
    </TR>
    <TR height='30'>
       <TD >
          {$user->getCity()}
        </TD>
    </TR>
    <TR >
        <TD >
           22 Miles Away
        </TD>
    </TR>
   <TR >
      <TD>
         {$user->getNoYrsWorkExperience()} yrs exp
      </TD>
   </TR>
   <TR >
      <TD >
        Salary: &#163; {$user->getSalaryAmount()}/hr 
      </TD>
   </TR>
    <TR>
        <TH ROWSPAN=3 width='150' height='55'>
          <table height='55'>
              <tr height='38'>
                 <td>
                     <a href='https://www.baby.com/profile/{$user->getId()}'>
                         <img src='https://www.bab.com/htmlEmailsIcons/contactMe2.png' width='113' height='38'  />  
                     </a>
                  </td>
             </tr>
            <tr height='10'>
              <td>
                 <a href='https://www.bab.com/profile/{$user->getId()}'>
                      View My Profile
                 </a>
               </td>
            </tr>
      </table>
   </TH>
 </TR>
    <TR>
       <TD  align='center'>
          Available From:
        </TD> 
   </TR>
   <TR>
     <TD>
        {$this->availFrom()}- {$this->availTill()}
     </TD> 
</TR>

}

以上代码包含在格式正确的 HTML 电子邮件中。为简单起见,我没有附上它。

非常感谢一些关于为什么它在 hotmail 上中断的建议。

【问题讨论】:

    标签: outlook html-email hotmail


    【解决方案1】:

    如上所述 - 不要使用浮点数。在任何电子邮件客户端上几乎不支持它。还注意到您的代码存在其他问题:

    1. 图片标签源没有结束引号
    2. 不要使用边距。最好使用 Cellpadding 或 cellspacing,但可以使用 TD 填充。
    3. 将所有 css 以手写形式(例如 -border-size: 1px;border-style:solid;border-color:#999999)更容易被电子邮件客户端识别和理解。
    4. 不一定是错误,而是标签中的多余空格。应该不是。
    5. 行跨数周围没有引号

    以下是我能想到的最好的帮助。如果没有更准确的信息来了解电子邮件中的内容,这是我能做的最好的事情。我在下面的代码中添加了一个开始表格标签和结束表格标签:

        <table>
      <tr>
    
    foreach ($this->getMembers() as $user)
    
    { 
    
    <td width='310' align="left" style="padding-left:5px; padding-top:10px; padding-bottom:10px;">
       <TABLE width='300' align="left" border='0' color='#FFFFFF' bgcolor='#FFFFFF' style='border-size: 1px; border-style: solid; border-color: #999999;'>
        <TR>
    
        <TH ROWSPAN="5" width='150' height='150'>
              <a href='https://www.bab.com/profile'>
                 <img src='https://www.bab.com' />  
              </a> 
          </TH>
           <TD width='150'>
            {$user->getFirstName()}&nbsp;&nbsp;(Aged: {$user->getActualAge()})
           </TD> 
        </TR>
        <TR height='30'>
           <TD >
              {$user->getCity()}
            </TD>
        </TR>
        <TR>
            <TD>
               22 Miles Away
            </TD>
        </TR>
       <TR>
          <TD>
             {$user->getNoYrsWorkExperience()} yrs exp
          </TD>
       </TR>
       <TR>
          <TD >
            Salary: &#163; {$user->getSalaryAmount()}/hr 
          </TD>
       </TR>
        <TR>
            <TH ROWSPAN="3" width='150' height='55'>
              <table height='55'>
                  <tr height='38'>
                     <td>
                         <a href='https://www.baby.com/profile/{$user->getId()}'>
                             <img src='https://www.bab.com/htmlEmailsIcons/contactMe2.png' width='113' height='38'  />  
                         </a>
                      </td>
                 </tr>
                <tr height='10'>
                  <td>
                     <a href='https://www.bab.com/profile/{$user->getId()}'>
                          View My Profile
                     </a>
                   </td>
                </tr>
          </table>
       </TH>
     </TR>
        <TR>
           <TD align='center'>
              Available From:
            </TD> 
       </TR>
       <TR>
         <TD>
            {$this->availFrom()}- {$this->availTill()}
         </TD> 
    </TR>
    </TABLE>
    </td>
    </tr>
    </table>
    

    【讨论】:

      【解决方案2】:

      首先,不要使用浮点数。大多数电子邮件客户端不会正确呈现它们。 改用 align ,就像在单元格外壳 'Available From:' 上所做的那样

      【讨论】:

        【解决方案3】:

        可能无法解决问题,但值得一试:所有其他参数都在单引号内,但 TH 的“rowspan”根本没有被引用。

        【讨论】:

          猜你喜欢
          • 2013-02-28
          • 2011-12-08
          • 2016-01-07
          • 2012-06-22
          • 2013-08-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-03-07
          相关资源
          最近更新 更多