针对 Gmail 电子邮件的 Internet Explorer 特定媒体查询或黑客攻击
Posted
技术标签:
【中文标题】针对 Gmail 电子邮件的 Internet Explorer 特定媒体查询或黑客攻击【英文标题】:Internet Explorer specfic media query or hack for Gmail email 【发布时间】:2019-12-12 23:46:50 【问题描述】:我正在处理电子邮件并希望切换特定于浏览器的部分。请检查以下代码:
<!--Showing on Internet explorer-->
<table class="showing-on-ie-gmail">...</table>
<!--Showing on Chrome-->
<table class="showing-on-chrome-gmail">...</table>
有没有办法做到这一点?
任何帮助都非常感谢。
提前致谢!
【问题讨论】:
【参考方案1】:看起来您想根据浏览器应用特定的 CSS 类。
您可以参考下面的示例,可能有助于识别 IE 和 Chrome。
识别 Internet Explorer 9 及更低版本:您可以使用条件 cmets 为您想要专门定位的任何版本(或版本组合)加载特定于 IE 的样式表。如下所示,使用外部样式表。
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->
识别 Internet Explorer 10 和 11:使用 -ms-high-contrast 创建媒体查询,在其中放置 IE 10 和 11 特定的 CSS 样式。因为 -ms-high-contrast 是 Microsoft 特有的(并且仅在 IE 10+ 中可用),所以只能在 Internet Explorer 10 及更高版本中解析。
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active)
/* IE10+ CSS styles go here */
识别 Google Chrome(29 岁以上):
@media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm)
.chrome
property: value;
参考资料:
(1)How to target only IE (any version) within a stylesheet?
(2)CSS3 Media Query to target only Internet Explorer (from IE6 to IE11+), Firefox, Chrome, Safari and/or Edge
【讨论】:
以上是关于针对 Gmail 电子邮件的 Internet Explorer 特定媒体查询或黑客攻击的主要内容,如果未能解决你的问题,请参考以下文章
错误:阅读电子邮件内容时出现 javax.mail.internet.MimeMultipart