简体   繁体   English

为什么GMAIL从我的HTML电子邮件中删除内联样式?

[英]Why does GMAIL removes inline style from my HTML email?

So I thought I am going to create an Html email in Gmail, it is going to be easy... I have read a few articles about it, when creating email it can only have inline style and nothing in the header. 所以我以为我要在Gmail中创建HTML电子邮件,这很容易...我读了一些有关它的文章,在创建电子邮件时,它只能具有内联样式,而标题中则没有任何内容。 ok. 好。

I open gmail..compose email...enter some random text...select the text...right click on it...inspect...edit html...and paste my html source code into where my random text was. 我打开gmail..compose电子邮件...输入一些随机文本...选择文本...右键单击它...检查...编辑html ...并将html源代码粘贴到我的随机文本中是。 Voila! 瞧! It looks fine. 看起来不错。 But when I send the email (or just save it as draft and view it) my inner divs background becomes the background of the outer div as well, it overlaps it. 但是,当我发送电子邮件(或仅将其保存为草稿并查看)时, 我的内部div背景也将成为外部div的背景,并且与之重叠。 I have tried to paste the whole source code, I have tried to paste <body>...</body> 我试图粘贴整个源代码,我试图粘贴<body>...</body>

and I have also tried to paste in only code from the most outer div. 而且我还尝试仅粘贴最外部div中的代码。 Why does gmail remove my style? 为什么gmail会删除我的样式?

输入的html代码 保存在HTML代码草稿中 This is my code: 这是我的代码:

 <!DOCTYPE html> <html> <head> </head> <body> <div style="color: #FFFFFF; padding:30px;"> <div style="border-radius: 25px; background-image: url(https://images.unsplash.com/photo-1529088363398-8efc64a0eb95?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=179403fa836a063432aec8ccc04ee248&auto=format&fit=crop&w=424&q=80); background-size: cover; background-repeat: no-repeat; background-position: center center; height: 400px; color: #ACA394; text-shadow: 1px 1px #000000; display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex; align-items: center; width: 100%"> <div style="width: 100%; text-align: center; background-color: rgb(0,0,0,0.5);"> <h1><b>Title</b> Subtitle</h1> <h2>Some text</h2> </div> </div> </div> </body> </html> 

The reason why it is because Gmail doesn't support flex . 之所以这样,是因为Gmail不支持flex supported CSS attributes 支持的CSS属性

Sadly, Gmail doesn't accept all types of CSS. 遗憾的是,Gmail不接受所有类型的CSS。 However, this link might be of some help to you. 但是, 此链接可能会对您有所帮助。 Good luck! 祝好运!

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

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