2016-06-22 62 views
0
<table width="100%;"> 
     <tr> 
     <td> <!--Right Space (Variable Width)--> </td> 
     <td> <!--content (Width Set - High Priority)--> </td> 
     <td> <!--Left Space (Variable Width --> </td> 
     </tr> 
    </table> 

我遇到了编码电子邮件的问题,我希望利润率根据屏幕大小而有所不同。它适用于媒体查询,但我意识到有一些电子邮件客户端不支持它们。我也尝试使用宽度百分比,但我希望内容在移动大小的屏幕上大约为90%,在大屏幕上大约为50%。我使用表格和空表格单元格来创建边距,并且只能使用内联样式。Html电子邮件 - 设置优先级

我想知道是否有一种方法来设置CSS属性,以便当屏幕宽度减小时,内容单元具有最高优先级的大小,左右“边距”将是宽度减小的。

回答

1

这听起来像是最大宽度的用例。您可以将元素的默认宽度设置为90%,但将最大宽度定义为桌面显示宽度的一半。由于Outlook不支持此属性,因此您还需要包含MSO条件。 CSS (for HTML email) reference guide

见下文:

<!--[if (gte mso 9) | (IE)]><table align="center" width="640"><tr><td align="center"><![endif]--> 
<table align="center" width="100%" style="max-width:640px;"> 
<tr> 
<td align="center"> 
    <!--[if (gte mso 9) | (IE)]><table width="320" align="center"><tr><td align="center"><![endif]--> 
    <table width="90%" align="center" style="max-width:320px;"> 
    <tr> 
    <td align="center">This content will be at 90% width of the container up to 320px wide, where it will stop</td> 
    </tr> 
    </table> 
    <!--[if (gte mso 9) | (IE)]></td></tr></table><![endif]--> 
</td> 
</tr> 
</table> 
<!--[if (gte mso 9) | (IE)]></td></tr></table><![endif]--> 
0

根据我的经验,电子邮件客户端只允许内联式。

根据您的要求,您需要设置代码的下方,

<div><!--email client body--> 

    <table width="650px;padding:50px;"><!--you can give padding not only margin properties of CSS--> 
     <table style="width:100%"> 
      <!--content--> 
       <table style="padding:20px"></table><!--Again added to padding instead of margin---> 
     </table> 

    </table> 

</div> 

注意:电子邮件的移动应用只支持在摆动浏览器这封邮件的内容,你打开电子邮件不摆动所有争辩。