简体   繁体   English

媒体查询不适用于电子邮件

[英]Media query isn't working for email

I'm trying to code a responsive design email-- I've combed through here and couldn't find anything that exactly helped. 我正在尝试编写响应式设计电子邮件-我在这里进行了梳理,找不到任何有帮助的东西。 I'm really not seeing any part of my @media query coming through-- the images are staying at the size I coded in the @media query, and not resizing back in browser. 我真的没有看到@media查询的任何部分通过-图片保持在我在@media查询中编码的大小,并且没有在浏览器中重新调整大小。 The mobile style for the fonts I've coded also aren't sticking. 我编码的字体的移动样式也不固定。 Here's some of the code: 这是一些代码:

<style type"text/css">
body {background-color: #e5e5e5}
p {
    font-size: 13px; 
    font-family: verdana; 
    line-height: 21px;
    color:#4B5460;
     }
a {
    font-family: verdana; 
    font-weight: bold; 
    text-decoration: underline; 
    color: #4B5460;
}
.footer_link {
    font-weight: normal;
    text-decoration: none;
    color:#0c5bba;
    font-size: 11px;
}

@media screen and (max-width:480px) {
    .graf_font {
        font-size: 16px;}
    }
    .reg_button {
        max-width:200px;
    }
    .mobile_hide {
        display: none;
    }
    .chiclets {
        max-width: 100px;
    }
    .snapshot {
        max-width:75px;
    }
}
</style>

Let me know if you need more code-- I'm a beginner with this, so I know I'm missing something glaring! 让我知道您是否需要更多代码-我是一个初学者,所以我知道我缺少明显的东西!

Thanks! 谢谢!

It looks like you have an extra closing bracket. 好像您有一个额外的结束括号。

.graf_font {
    font-size: 16px;} /* <-- remove this bracket */
}

Also check to make sure the email client your in even supports media queries. 还要检查以确保您的电子邮件客户端甚至支持媒体查询。 https://litmus.com/help/email-clients/media-query-support/ https://litmus.com/help/email-clients/media-query-support/

Max-Width is not fully supported for email. 电子邮件不完全支持最大宽度。 I have found using percentages to be a useful alternative (eg width=80%). 我发现使用百分比是一种有用的替代方法(例如,宽度= 80%)。 If you can make images take up a certain percentage of the screen or table cell on mobile images instead of being a particular pixel width it may be more successful. 如果您可以使图像占据移动图像上屏幕或表格单元的一定百分比,而不是占据特定的像素宽度,则可能会更成功。 If you still aren't having success, try adding !important after your CSS. 如果仍然没有成功,请尝试在CSS之后添加!important。

Also, you'll want to style your text inline, as a lot of that will get stripped by different email clients. 另外,您将需要内联样式化文本,因为很多文本将被不同的电子邮件客户端剥离。

I would also suggest that you check out https://litmus.com/community . 我还建议您查看https://litmus.com/community It is a newly free source with a lot of up-to-date info on email design and people who know a lot more about email design than me. 它是一个新的免费资源,其中包含有关电子邮件设计的最新信息,并且比我更了解电子邮件设计的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM