Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php class to inline css styles?

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.

like image 304
MintDeparture Avatar asked Oct 21 '10 18:10

MintDeparture


4 Answers

Pure PHP solution: https://github.com/tijsverkoyen/CssToInlineStyles (used by laravel).

tijsverkoyen/css-to-inline-styles if using composer.

like image 176
Leith Avatar answered Oct 19 '22 04:10

Leith


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.

like image 33
ArnAud Avatar answered Nov 04 '22 19:11

ArnAud


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. "

like image 9
Tom Avatar answered Nov 04 '22 19:11

Tom


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...)

like image 3
Andrew Vit Avatar answered Nov 04 '22 19:11

Andrew Vit