将外部CSS转换为Rails中邮件的内联CSS [英] Converting External CSS to Inline CSS for Mail in Rails

查看:132
本文介绍了将外部CSS转换为Rails中邮件的内联CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个应用程序,发送风格很大的电子邮件,除了Google的Gmail之外,还需要客户端工作。我研究了这个问题,它看起来像是从外部文件中剥离CSS,或者嵌套在样式标签中的CSS。一个简单的方法是将外部文件移动到内联方式?

I am trying to create an application that will send out style-heavy emails and have required clients working except Google's Gmail. I researched the issue and it looks like Gmail strips out CSS from external files or CSS nested in the 'style' tag. Does an easy way exist of moving style from an external file to being inline?

需要做的事情:

<style>
.wide { width: 100px; }
.cell { display: block; }
</style>
<span class="wide cell">Sample</span>

并将其转换为:

<div class="wide cell" style="width: 100px; display: block;">Sample</div>

谢谢!

推荐答案

这里有几个您可以查看的宝石:

Here are couple of gems you can check out:

  • premailer or premailer-rails for rails
  • mail_style
  • premailer plus (fork of the above version)
  • awesome_email
  • roadie

当时我没有获胜者写这个答案但是 premailer 似乎是最新的。

I have no winner at the time writing this answer but premailer seems to be most up-to-date.

这篇关于将外部CSS转换为Rails中邮件的内联CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆