简体   繁体   English

使用 CSS flexbox 和 email 模板的网格

[英]Using CSS flexbox and grid for email templates

Can we use CSS flexbox and grid for making layouts in html email templates? CSS flexboxgrid可以在 html email 模板中进行布局吗? And apart form using tables what possible differences are there in simple html and email templates?除了使用表格之外,简单的 html 和 email 模板可能存在哪些差异?

Traditionally, HTML has been the backbone of email, so the most supported way to do email templates is to use the table tag.传统上,HTML 一直是 email 的主干,所以最受支持的做 email 模板的方式是使用 table 标签。

is supported in 100% of today's email clients, so no issues there. 今天的 email 客户端 100% 都支持它,所以没有问题。 Grid, however, isn't well supported at all, although display:flex surprisingly works in 84.85% of email clients (it actually has better support than media queries.). 然而,网格并没有得到很好的支持,尽管 display:flex 在 email 个客户端中的 84.85% 令人惊讶地工作(它实际上比媒体查询有更好的支持。)。

However, flex's related CSS properties (flex-wrap:, align-items:, flex-direction:, justify-content:, etc.) have terrible support — tables are the better choice.然而,flex 的相关 CSS 属性(flex-wrap:、align-items:、flex-direction:、justify-content: 等)的支持很差——表格是更好的选择。

The information is accurate as at 2022.该信息截至 2022 年是准确的。

Source: https://designmodo.com/html-css-emails/来源: https://designmodo.com/html-css-emails/

you can use this website to see what tags you can or can not use: for example flex:您可以使用此网站查看可以或不能使用哪些标签:例如 flex:

https://www.caniemail.com/search/?s=flex https://www.caniemail.com/search/?s=flex

there are no differences between normal css and email css, the only thing is different clients.正常的css和email css没有区别,只是客户端不同而已。 in normal situations your client is a web browser which is quite feature rich, but in emailingm your client is a email client, like gmail, which can only understand some parts of css and not all of them在正常情况下,您的客户端是一个功能非常丰富的 web 浏览器,但在 emailingm 中,您的客户端是一个 email 客户端,例如 gmail,它只能理解 css 的某些部分,而不是全部

my personal choice was to use MJML.我个人的选择是使用 MJML。 its a library for handling your email templates.它是一个用于处理 email 模板的库。 quite easy to learn and to use.非常容易学习和使用。

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

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