Does Gmail support CSS classes?

旧巷老猫 提交于 2019-12-22 12:15:37

问题


The title is really just the shortened version of the question. I'm aware of Gmail's limited CSS support, but I was reading "Guide to CSS support in email", which has a note for Gmail's support of .class and #id selectors:

(!) Works in some instances if CSS is inlined before or during campaign import

What does this actually mean as far as CSS support is concerned? To me, it sounds like it's just suggesting to use a preprocessor to take any style declarations and apply them to the matched elements.

Is there a trick to being able to use CSS classes in an HTML email in the Gmail client?


回答1:


Gmail will only use CSS that is inline. It will not allow internal or external style sheets. Or rather I have found its support to be unreliable at best. Use this tool to do to convert internal and external style into inline for you:

http://inlinestyler.torchboxapps.com/styler/

It even tells you how well your document is supported in different email clients. This will allow you to develop in a more sane fashion, and only convert it at the end.




回答2:


Gmail does support .class and #id selector and internal style sheets (meaning tags) at the moment. You should keep in mind that some of the styles are modified by Gmail. You can't for example use negative margins or box shadows atm.

I'm not sure about external style sheets though. I haven't tested those.



来源:https://stackoverflow.com/questions/12391262/does-gmail-support-css-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!