2016-06-22 65 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> 

注意:電子郵件的移動應用只支持在擺動瀏覽器這封郵件的內容,你打開電子郵件不擺動所有爭辯。