html - 电子邮件中的表格未在 MS Outlook 中居中

标签 html css html-table outlook

我在 HTML 电子邮件中使用以下标记使表格居中。它在大多数电子邮件客户端中工作正常,但出于某种原因,在 Outlook 中,表格显示为左对齐,即使我在左侧和右侧使用了边距自动。我做错了什么吗?

 <table class="email-survey-type type_question" style=" width: 80%; text-align: center;  margin: 0 auto 20px auto;;" bgcolor="#fff" border="0" cellpadding="0" cellspacing="0">

    <div style="font-family: 'Helvetica Nueue', Arial, sans-serif; padding: 20px; background: #fff;">

    <div style="font-family:'Helvetica Nueue', Arial, sans-serif; background: #fff; max-width: 550px; margin: 0 auto;">
        
        
    <style type="text/css">
        @media only screen and (min-width: 430px) { .maxW { width:400px !important; } }
      </style>
        
            
            <div class="maxW" style="max-width:400px;margin: 0 auto;">

                   
                   </div><table width="100%" bgcolor="#fff" border="0" cellpadding="0" cellspacing="0">
               <tbody><tr style="text-align: center;">

                   <!--[if (gte mso 9)|(IE)]><table width="400" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td><![endif]-->
                   </tr></tbody></table>
                   
                   <table class="email-survey-type type_question" style=" width: 95%; text-align: center; margin: 0 auto; " bgcolor="#fe5777" border="0" cellpadding="0" cellspacing="0">
                       <tbody><tr>
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="0" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #c0392b; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;">
                                    </a>
                                </td>
                               
                           
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="2" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #e74c3c; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;">
                                    </a>
                                </td>
                               
                           
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="4" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #f65c4c; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;">
                                    </a>
                                </td>
                               
                           
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="6" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #e76430; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;">
                                    </a>
                                </td>
                               
                           
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="8" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #2ecc71; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;">
                                    </a>
                                </td>
                               
                           
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="10" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #1abc9c; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;">
                                    </a>
                                </td>
                               
                           
                       </tr>
                   </tbody></table>
                   <table class="email-survey-type type_question" style=" width: 80%; text-align: center;  margin: 0 auto 20px auto;;" bgcolor="#fff" border="0" cellpadding="0" cellspacing="0">
                       <tbody><tr>
                          
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="1" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #c0392b; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;">
                                    </a>
                                </td>
                               
                           
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="3" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #e74c3c; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;" >
                                    </a>
                                </td>
                               
                           
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="5" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #e76430; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;" >
                                    </a>
                                </td>
                               
                           
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="7" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #2ecc71; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;" >
                                    </a>
                                </td>
                               
                           
                               
                           
                               
                                <td>
                                    <a href="#">
                                        <img alt="9" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/340px-Apple_logo_black.svg.png" width="60" style="max-width: 60px; width:60px; color: #1abc9c; font-weight: bold; font-size: 16px; line-height: 50px; text-align: center;">
                                    </a>
                                </td>
                               
                           
                               
                           
                       </tr>
                   </tbody></table>

                   </div>
                   <!--[if (gte mso 9)|(IE)]></td></tr></table><![endif]-->
                
            

            
            


            
              <table width="100%" bgcolor="#fff" border="0" cellpadding="0" cellspacing="0">
                <tbody><tr style=" ">
                    <td style="padding: 20px;"><p style="text-align: center; margin: 0 0 5px; line-height: 1;font-family:'Helvetica Nueue', Arial, sans-serif;font-size:18px;" class="bottom_text_en-target show-parent-2">Lorem ipsum dolor</p></td>
                </tr>
                
            </tbody></table>
        

        

        <!-- End links -->
    </div>

最佳答案

您的电子邮件很可能会有更多错误和问题,您正在起诉 <div>不受支持或有一些问题。 Outlook 2007-2016 不完全支持边距,它有问题你可以 check it here .

使用align="center"

代码:

<table align="center" class="email-survey-type type_question" style=" width: 80%; text-align: center;" bgcolor="red" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      Your code
    </td>
  </tr>
</table>

关于html - 电子邮件中的表格未在 MS Outlook 中居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50936574/

相关文章:

html5进度条没有动画

html - 更正带有虚线边框的框的 HTML 代码

CSS 下拉菜单在 IE 中不起作用(所有版本)

html - 表格内单个 TD 的 CSS 填充

angular - 使用 Angular Material 表进行多文本搜索

html - css 表格宽度无法正常工作

javascript - 将 Div 的内容放在顶部

html - 使用 bootstrap 3 获得悬停效果

javascript - 按下 Tab 时替换输入文本(Chrome 扩展)

html - 悬停时更改按钮中的图像