HTML移动电子邮件不使用媒体查询



正如标题所示,我的媒体查询被忽略了。我首先要说的是,我知道支持媒体查询的电子邮件客户端很少。但根据一些消息来源,Gmail和android版Outlook都应该支持媒体查询。

我尝试过各种解决方案,但都无济于事。甚至这个基本代码都不是从Acid 上的电子邮件中获取的

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Titel</title>
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<style>
@media only screen and (max-width:608px){
.test{
display: none !important;
}
}
</style>
</head>
<body style="margin:0;padding:0;min-width:100%;background-color:#ffffff;">
<div style="display:none;font-size:1px;color:#ffffff;line-height:1px;max-height:0px;max-width:0px;opacity:0;overflow:hidden;"></div>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="min-width: 100%;" role="presentation">
<tr>
<td align="center">
<div class="test">
This should be hidden
</div>
<div>
This should not
</div>
</td>
</tr>
</table>
</body>
</html>

我知道在html电子邮件中,表和td比div更受欢迎,但结果是一样的。起初,我通过outlook 2016发送邮件,但我担心它会剥去我的头标签,所以我停了下来。在网络浏览器中一切正常,但在电子邮件客户端中则不然。

编辑:所以我解决了我的问题。这只是电子邮件客户端设置和我发送邮件的方式的不幸结合。

因此,对于任何迷路的人,请确保:

  • 你不从outlook发送电子邮件,它会去掉head标签
  • 如果你通过gmail应用程序测试你使用的是gmail帐户,否则它不会显示样式标签中的任何内容

确保不要通过Outlook发送电子邮件,因为它在发送时会去掉头部标签,如果你不使用Gmail帐户,也不要通过Gmail应用程序进行测试。

最新更新