php class to inline css styles?

2020-06-12 03:28发布

I was over at MailChimp's css inliner http://www.mailchimp.com/labs/inlinecss.php and I was wondering if there are any classes out there that can do this, I'd love to have it in my email code instead of going all the way over to MailChimp.

Basically I'm looking for the code, behind the page or something very similar.

Cheers.

6条回答
倾城 Initia
2楼-- · 2020-06-12 03:30

I was looking for the same thing tonight and I found this library https://github.com/christiaan/InlineStyle ,which does what I think you want.

It even understand selectors like ul > li and such.

查看更多
太酷不给撩
3楼-- · 2020-06-12 03:43

The link in the OP appears to be gone, but MailChimp offers a style-to-inline convertor for free with no signup here:

http://beaker.mailchimp.com/inline-css

Still have to go "all thet way over to Mailchimp", though!

查看更多
Emotional °昔
4楼-- · 2020-06-12 03:44

Emogrifier did not work for me, so I have developed this: https://github.com/djfm/cssin. I've tried several other libs and none worked on my HTML files, my lib is pretty OK I think.

查看更多
不美不萌又怎样
5楼-- · 2020-06-12 03:49

How's this?

https://www.myintervals.com/emogrifier.php

"... Emogrifier automagically transmogrifies your HTML by parsing your CSS and inserting your CSS definitions into tags within your HTML based on your CSS selectors. You can either use the form below to paste your HTML or CSS, or if you're more technically inclined, you can download the PHP source code and use it in your own applications. "

查看更多
Evening l夕情丶
6楼-- · 2020-06-12 03:50

You can try Premailer. The source is available on Github. (Just noticed your tag is PHP and Premailer is Ruby, so this might not count as a real answer for you...)

查看更多
成全新的幸福
7楼-- · 2020-06-12 03:52

I was looking for the same thing (PHP based, downloadable, open source), but couldn't find it, so I created the following proxy/wrapper for the open source ruby library: https://github.com/onassar/PHP-Premailer

Hope it's helpful.

查看更多
登录 后发表回答