2017-04-07 147 views
0

由于某些原因,当我在表格中设置单元格的宽度时,它不会影响单元格的宽度。仅供参考我使用嵌入式样式的邮件。宽度不适用于表格单元

<table cellpadding="0" cellspacing="0" width="100%"> 
    <tr> 
     <td align="center"> 
      <table cellpadding="0" cellspacing="0" width="550" style="width: 100%; max-width: 550px; text-align: center; border: 1px solid #003a4b;"> 
       <tr> 
        <td style="padding-top: 10px;"><span style="font-family: helvetica, sans-serif; font-size: 37px; font-weight: bold; color: #93d600; border-bottom: 1px solid #003a4b;">Hunters Conference 2017</span></td> 
       </tr> 

       <tr> 
        <td width="80%" style="padding: 20px 0; background-color: blue;"><span style="font-family: helvetica, sans-serif; font-size: 16px; color: #003a4b; background-color: red;">Fyber were honoured to attend and support such a fantastic conference, congratulations to everyone that won a prize on our wheel of fortune!</span></td> 
       </tr> 

       <tr> 
        <td width="80%" style="padding: 0 55px; padding-bottom: 20px;"><span style="font-family: helvetica, sans-serif; font-size: 16px; color: #003a4b;">We hope you all had a great day, we enjoyed catching up with everyone and it was nice to see our clients face to face. </span></td> 
       </tr> 

       <!--[if mso]> 
       <tr> 
        <td style="padding-bottom: 20px;"> 
         <img src="https://gallery.mailchimp.com/b083c967cd22e35ab4ce75e7a/images/2c3e3b5e-9a9f-4864-a36f-6359b0dd4b75.jpg" alt="Spinning Wheel" width="550" style="width: 100%; max-width: 550px;"> 
        </td> 
       </tr> 
       <![endif]--> 

       <!--[if !mso]><!-- --> 
       <tr> 
        <td style="padding-bottom: 20px;"> 
         <img src="https://gallery.mailchimp.com/b083c967cd22e35ab4ce75e7a/images/19e810cd-df47-474b-aa47-3f33bf26922a.gif" alt="Spinning Wheel" width="550" style="width: 100%; max-width: 550px;"> 
        </td> 
       </tr> 
       <!--<![endif]--> 
      </table> 
     </td> 
    </tr> 
</table> 

https://jsfiddle.net/xmbsemje/

回答

1

TD的默认行为添加width是填写表格的宽度,所以如果你只有一个<td>每r无论你做什么,它总是会走满表的全部宽度。 一种方法是在该td内创建一个表格,并将宽度放在表格上。在电子邮件中左右填充也不起作用,因此创建具有定义宽度的表并将它们居中放置是最佳选择。

另一种方法是将间隔单元放在左侧和右侧以提供填充空间。我使用第一种方法修改了代码(只是带有蓝色/红色和白色背景的文本单元格)。

请注意:我并没有解决所有的代码,只要改变一对夫妇,让你开始

<table cellpadding="0" cellspacing="0" width="100%"> 
 
    <tr> 
 
     <td align="center"> 
 
      <table cellpadding="0" cellspacing="0" width="550" style="width: 100%; max-width: 550px; text-align: center; border: 1px solid #003a4b;"> 
 
       <tr> 
 
        <td style="padding-top: 10px;"><span style="font-family: helvetica, sans-serif; font-size: 37px; font-weight: bold; color: #93d600; border-bottom: 1px solid #003a4b;">Hunters Conference 2017</span></td> 
 
       </tr> 
 

 
       <tr> 
 
        <td align="center" style="padding: 20px 0; background-color: blue;"> 
 
        <table border="0" cellpadding="0" cellspacing="0" style="width:80%;"> 
 
         <tr> 
 
         <td align="left"><span style="font-family: helvetica, sans-serif; font-size: 16px; color: #003a4b; background-color: red;">Fyber were honoured to attend and support such a fantastic conference, congratulations to everyone that won a prize on our wheel of fortune!</span></td> 
 
         </tr> 
 
        </table> 
 
        </td>      
 
       </tr> 
 

 
       <tr> 
 
        <td align="center" style="padding: 20px 0;"> 
 
        <table border="0" cellpadding="0" cellspacing="0" style="width:80%;"> 
 
         <tr> 
 
         <td align="left"><span style="font-family: helvetica, sans-serif; font-size: 16px; color: #003a4b;">We hope you all had a great day, we enjoyed catching up with everyone and it was nice to see our clients face to face. </span></td> 
 
         </tr> 
 
        </table> 
 
        </td> 
 
       </tr> 
 

 
       <!--[if mso]> 
 
       <tr> 
 
        <td style="padding-bottom: 20px;"> 
 
         <img src="https://gallery.mailchimp.com/b083c967cd22e35ab4ce75e7a/images/2c3e3b5e-9a9f-4864-a36f-6359b0dd4b75.jpg" alt="Spinning Wheel" width="550" style="width: 100%; max-width: 550px;"> 
 
        </td> 
 
       </tr> 
 
       <![endif]--> 
 

 
       <!--[if !mso]><!-- --> 
 
       <tr> 
 
        <td style="padding-bottom: 20px;"> 
 
         <img src="https://gallery.mailchimp.com/b083c967cd22e35ab4ce75e7a/images/19e810cd-df47-474b-aa47-3f33bf26922a.gif" alt="Spinning Wheel" width="550" style="width: 100%; max-width: 550px;"> 
 
        </td> 
 
       </tr> 
 
       <!--<![endif]--> 
 
      </table> 
 
     </td> 
 
    </tr> 
 
</table>

0

最后tdwidth550px所以不会影响你的width80%;

这样你就可以spantag