2016-09-09 24 views
0

我的電子郵件在任何其他計算機或移動顯示中都可以正常使用,但Gmail應用程序和筆記本電腦中的Gmail除外。 2個問題:電子郵件編碼:Gmail和Gmail應用程序似乎忽略了我的CSS

  • 我加在CSS一個@media代碼,以使圖像上的移動(寬度:100%)觀察時爲響應,但Gmail應用(在三星電話和蘋果測試的兩種電話)似乎無視它。所以我的圖像顯得較小,固定寬度爲大屏幕指定。 這裏是結果:http://screencast.com/t/nm3jyc47K。預期的結果是讓圖像充滿100%的表格(如果我們排除隔離物,幾乎所有的屏幕),並且顯然居中。

  • 在Gmail筆記本電腦網站上,表格之間的間隔符似乎被忽略,因此內聯元素相互接觸。結果如下:http://screencast.com/t/3D7H0Fqly。預期的結果是中間有一個24像素的間隔。 (PD:別爲我擔心的大小,我做了一些測試,在桌面上的大小以適當的)

這裏是圖片,3張圖片和2個間隔之間的HTML代碼。

<table align="left" border="0" cellpadding="0" cellspacing="0" class="m-width w-170" style="max-width:100%;"> 
    <tbody> 
    <tr> 
     <td align="center"> 
     <a href="img-1.png" style="border:none; display:block;height:136px" width="170px" /></a> 
     </td> 
    </tr> 
    <tr> 
     <td height="20">&nbsp;</td> 
    </tr> 
    </tbody> 
</table> 

<!--[if mso]></td><td width="24"><![endif]--> 

<table align="left" border="0" cellpadding="0" cellspacing="0" class="m-width w-24" style="max-width:24px;"> 
    <tbody> 
    <tr> 
     <td height="1" style="font-size:1px;line-height:1px">&nbsp;</td> 
    </tr> 
    </tbody> 
</table> 
<!--[if mso]></td><td width="170" valign="top"><![endif]--> 

<table align="left" border="0" cellpadding="0" cellspacing="0" class="m-width w-170" style="max-width:100%;"> 
    <tbody> 
    <tr> 
     <td align="center"> 
     <a href="img-2.png" style="border:none; display:block;height:136px" width="170px" /></a> 
     </td> 
    </tr> 
    <tr> 
     <td height="20">&nbsp;</td> 
    </tr> 
    </tbody> 
</table> 

<!--[if mso]></td><td width="24"><![endif]--> 

<table align="left" border="0" cellpadding="0" cellspacing="0" class="m-width w-24" style="max-width:24px;"> 
    <tbody> 
    <tr> 
     <td height="1" style="font-size:1px;line-height:1px">&nbsp;</td> 
    </tr> 
    </tbody> 
</table> 

<!--[if mso]></td><td width="170" valign="top"><![endif]--> 

<table align="left" border="0" cellpadding="0" cellspacing="0" class="m-width w-170" style="max-width:100%;"> 
    <tbody> 
    <tr> 
     <td align="center"> 
     <a href="img-3.png" style="border:none; display:block;height:136px" width="170px" /></a> 
     </td> 
    </tr> 
    <tr> 
     <td height="20">&nbsp;</td> 
    </tr> 
    </tbody> 
</table> 

而且現在的CSS代碼,在電子郵件的頭部:

<style type="text/css"> 
body{width:100% !important;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;margin:0;padding:0;background-color:#ffffff} 
* {-webkit-font-smoothing:antialiased} 
.ExternalClass * {line-height:100%} 
table td {border-collapse:collapse} 
.wlf {width:600px} 
.w-420 {width:420px} 
.w-170 {width:170px} 
.w-120 {width:120px} 
.w-24 {width:24px} 
.w-15 {width:15px} 
@media only screen and (max-width:590px) { 
    .full-width {width:100% !important} 
    .m-width {width:100% !important;max-width:100% !important;float:none !important} 
    .m-block {display:block} 
    .m-none {display:none} 
    .m-img-ft {width:100% !important;height:auto !important;max-width:250px !important} 
    div {box-sizing:border-box !important} 
} 
</style> 

再次,我沒有任何問題與所有其他電子郵件程序。任何想法可能是錯誤的,以解決這兩個問題? (如果沒有其他的損害顯示器?)

感謝

回答

0

不幸的是,你發現大部分HTML電子郵件開發商有頭髮很少,並在其左眼有輕微抽搐的原因。不幸的是,每個電子郵件客戶端都沒有用於HTML電子郵件的「標準」,因此您不僅可以接受哪些標籤/樣式,而且可以確切瞭解每個電子郵件客戶端的具體內容。

對於你的問題,它似乎忽略它的原因是因爲它是完全剝離你的風格標籤。 (ref)Gmail應用程序(桌面版和移動版)幾乎將所有內容都刪除了,而Gmail網絡客戶端的版本爲very limited 'hacky' support on stylesheets

一個很好的資源,看看有什麼是主要的電子郵件客戶端接受:CampaignMonitor/CSS

請記住,當你解決它在Gmail,它可能會風打破它不同的電子郵件客戶端。我會建議獲得酸性或石蕊試劑等電子郵件的酸性測試服務。

您可能需要先開始設計Gmail應用程序,然後使用CSS /'Ghost表格'或MSO條件使其適用於桌面。

用於流體響應模板樣品地方:

http://tedgoas.github.io/Cerberus/

https://www.emailonacid.com/blog/article/email-marketing/our-gift-to-you-a-free-fluid-hybrid-email-template

http://labs.actionrocket.co/the-hybrid-coding-approach-2

+0

好吧,我明白,這解釋了一切。所以根據你的回答,我設法解決了問題n°2的問題,在我的spacers中添加了一個內聯css:width:24px ;.這使得gmail可以閱讀並正確應用它們。除了移動Gmail應用程序外,這個電子郵件現在無處不在。 但是在這裏,我沒有任何線索知道如何去做,因爲它帶有媒體查詢:僅@media屏幕和(max-width:590px)。而這個我相信在地球上沒有辦法使用它。我需要的表格是: –

+0

我需要的表格是: 寬度:100%!重要; max-width:100%!important; float:none!important 而且圖像是: 寬度:100%!重要; 身高:自動!重要; max-width:250px!important 電子郵件程序員通常如何將它應用於gmail移動應用程序? –

+0

我編輯了我的答案,包括獲得Fluid Responsive模板的地方。這確實是Gmail應用程序中獲取響應電子郵件的唯一解決方案,它仍將繼續適用於大多數桌面客戶端。 – Gortonington

1

Gmail不支持的<style>標籤,所以你必須聯所有CSS。所有其他電子郵件客戶端都支持<style>標籤,因此如果它不適用於Gmail,我們將能夠像網頁一樣編寫html電子郵件。手動嵌入CSS是最安全的,儘管有一些CSS內聯工具可以加快速度。

關於墊片,像這樣跨越電子郵件客戶端的工作原理:

<!-- Clear Spacer : BEGIN --> 
    <tr> 
     <td height="40" style="font-size: 0; line-height: 0;"> 
      &nbsp; 
     </td> 
    </tr> 
<!-- Clear Spacer : END --> 

注:我寫Gortonington的回答中引用的第一個樣本模板(你好!),並可以保證該範圍內的所有CSS和墊片回購在Gmail/Gmail應用程序中工作。

相關問題