iOS Outlook应用仅在HTML电子邮件中允许单个媒体查询

发布于 2025-02-12 18:50:36 字数 876 浏览 3 评论 0原文

我想在HTML电子邮件中以2个不同的屏幕宽度和媒体查询更改一些文本的字体大小。除了在iOS的Outlook应用程序中,所有设备/客户端都可以在所有设备/客户端上工作。

这是Inline HTML的一个示例:

<td class="para" align="left" style="border-collapse: collapse; mso-line-height-rule: exactly; font-family: Times, 'Times New Roman', serif; font-size: 17px; color: #333333; line-height: 24px; text-align: left; text-indent: 29px; padding: 20px 0 0 0;"><span style="font-family: Times, 'Times New Roman', serif !important;">some text here</span></td>

然后,我有以下CSS:

<style>
@media only screen and (max-width:600px) {
.para {
    font-size: 18px !important;
}
}
@media only screen and (max-width:445px) {
  .para {
    font-size: 20px !important;
}
}
</style>

如果我只有一个媒体查询,则它在iOS的Outlook应用程序中按预期工作,但是当我添加第二个媒体时,媒体查询无效,全部。

我是做错了什么还是这只是您必须与iOS Outlook一起使用的事情?

I am wanting to change the font size of some text in an HTML email at 2 different screen widths with media queries. This works as expected on all devices/clients except in Outlook App for iOS.

Here is an example of the inline HTML:

<td class="para" align="left" style="border-collapse: collapse; mso-line-height-rule: exactly; font-family: Times, 'Times New Roman', serif; font-size: 17px; color: #333333; line-height: 24px; text-align: left; text-indent: 29px; padding: 20px 0 0 0;"><span style="font-family: Times, 'Times New Roman', serif !important;">some text here</span></td>

Then I have the following CSS:

<style>
@media only screen and (max-width:600px) {
.para {
    font-size: 18px !important;
}
}
@media only screen and (max-width:445px) {
  .para {
    font-size: 20px !important;
}
}
</style>

If I only have one of the media queries, it works as expected in the Outlook App for iOS, but when I add the second one it no media queries work at all.

Am I doing something wrong or is this just something that you have to work around with iOS Outlook?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴情 2025-02-19 18:50:36

问题归因于其实现中的错误,如下所示: https:// github 。

​空格和创建双卷发括号,}}是关闭样式块并启动一个新的块,即:

<style>
@media only screen and (max-width:600px) {
.para {
    font-size: 18px !important;
}
}
</style>
<style>
@media only screen and (max-width:445px) {
  .para {
    font-size: 20px !important;
}
}
</style>

The issue is due to a bug in their implementation, as documented here: https://github.com/hteumeuleu/email-bugs/issues/92

The easiest solution, since perhaps your minifying code may be removing whitespace and creating the double curly braces, }}, is to close the style block and start a new one, i.e.:

<style>
@media only screen and (max-width:600px) {
.para {
    font-size: 18px !important;
}
}
</style>
<style>
@media only screen and (max-width:445px) {
  .para {
    font-size: 20px !important;
}
}
</style>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文