fritx / css-inline

Inline css into html dom
https://www.npmjs.com/package/css-inline
8 stars 0 forks source link

css-inline

Inline css into html dom

It is very simple right now

It is based on fritx/css-obj

Usage

Source:

<!-- only one tag that wraps -->
<!-- to which body/html will be
  implicitly auto-parented
  while inlining -->
<div class="box">
  <img src="https://github.com/fritx/css-inline/raw/master/xxx">
</div>
.box {
  background-color: blue;
}
body > .box {
  color: red;
}
.box img {
  width: 100%;
  height: auto;
}

Inlining:

var inlineCss = require('css-inline')
inlineCss(html, css, function(err, inlined){
  console.log(inlined)
})

Outputs:

<div class="box" style="background-color:blue;color:red;">
  <img src="https://github.com/fritx/css-inline/raw/master/xxx" style="width:100%;height:auto;">
</div>