开发者

Do you know any tools to switch from external/internal stylesheet to inline style?

I'm looking for a tool which uses the CSS selectors within a stylesheet to generate the selected inline style.

E.g :

<head>
<style text="text/css">
a {
   text-decoration: none;
}

#a, #b, #c
{
   position: absolute;
}

#b
{
   left: 50px;
}
</style>
</head>
<body>
  <div id="a">
    <p>
     <a href="http://www.stackoverflow.com">SO</a>
    </p>
  </div>
  <div id="b">
  </div>
  <div id="c">
  </div>
</body>

will be :

<body>
  <div id="a" style="position: absolute">
    <p>
     <a href="http://www.stackoverflow.com" style="text-decoration: none;">SO</a>
    </p>
  </div>
  <div id="b" style="position: absolute; left: 50px;">
  </div>
  <div id="c" style="position: absolu开发者_JS百科te">
  </div>
</body>

Any ideas ?!

EDIT :

I want to do that to be able to 'style' email in most email client, especially for gmail, which doesn't support external or even internal stylesheet.


you can do it with the following online application:

Convert CSS to inline styles


If you want to pass it through an API and do it automatically from within your application, check out http://premailer.dialect.ca.

It's a lot easier to use an API integrated into your app if you're developing one, since you don't have to generate the email contents and

If you're using ruby, the project is open sourced here so you can integrate it directly.

Or if you're using node.js, there's a wrapper that makes the API even easier to use: https://github.com/JedWatson/node-premailer

If you prefer to use a web form, MailChimp have a great tool here. Mailchimp have an API too if you've got an account.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜