@dramaorg/dolores-sunt

2.10.68 • Public • Published

Pixrem

Build Status

PostCSS plugin that generates pixel fallbacks for rem units.

Notes

This is a fork of the original https://github.com/robwierzbowski/node-pixrem by robwierzbowski robwierzbowski. With additional work done by onigoetz and philiprenich.

npm install --save postcss pixrem

Installation

npm install --save postcss pixrem

Usage

Pixrem is a CSS post-processor that, given CSS and a root em value, returns CSS with pixel unit fallbacks or replacements. It's based on browser data so only needed fallbacks will be added. Basically, it's for IE8 or less, and for IE9 & IE10 in the font shorthand property and in pseudo-elements.

Example

'use strict';
var fs      = require('fs');
var pixrem  = require('pixrem');
var postcss = require('postcss');

var css = fs.readFileSync('main.css', 'utf8');
var processedCss = postcss([pixrem]).process(css).css;

fs.writeFile('main.with-fallbacks.css', processedCss, function (err) {
  if (err) {
    throw err;
  }
  console.log('IE8, you\'re welcome.');
});

Pixrem takes this:

.sky {
  margin: 2.5rem 2px 3em 100%;
  color: blue;
}

@media screen and (min-width: 20rem) {
  .leaf {
    margin-bottom: 1.333rem;
    font-size: 1.5rem;
  }
}

And returns this:

.sky {
  margin: 40px 2px 3em 100%;
  margin: 2.5rem 2px 3em 100%;
  color: blue;
}

@media screen and (min-width: 20rem) {
  .leaf {
    margin-bottom: 1.333rem;
    font-size: 1.5rem;
  }
}

Options

Type: Object | Null Default: {rootValue: 16, replace: false, atrules: false, html: true, browsers: 'ie <= 8', unitPrecision: 3}

  • rootValue the root element font size. Can be px, rem, em, %, or unitless pixel value. Pixrem also tries to get the root font-size from CSS (html or :root) and overrides this option. Use html option to disable this behaviour.
  • replace replaces rules containing rems instead of adding fallbacks.
  • atrules generates fallback in at-rules too (media-queries)
  • html overrides root font-size from CSS html {} or :root {}
  • browsers sets browser's range you want to target, based on browserslist
  • unitPrecision control the significant digits after the decimal point

Contribute

Report bugs and feature proposals in the Github issue tracker. Run tests with npm test. In lieu of a formal styleguide, take care to maintain the existing coding style.

License

MIT

Bitdeli Badge

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.10.685latest

Version History

VersionDownloads (Last 7 Days)Published
2.10.685
2.10.670
2.10.660
2.10.650
2.10.640
2.10.630
2.9.630
2.9.620
2.8.620
2.8.610
2.8.600
2.8.590
2.7.590
2.7.580
2.7.570
2.7.560
2.7.550
2.7.540
2.7.530
2.7.520
2.7.510
2.7.500
2.7.490
2.7.480
2.7.470
2.6.470
2.6.460
2.6.450
2.5.450
2.5.440
2.5.430
2.5.420
2.5.410
2.5.400
2.5.390
1.5.390
1.5.380
1.5.370
1.5.360
1.5.350
1.5.340
1.5.330
1.5.320
1.5.310
1.5.300
1.5.290
1.4.290
1.3.290
1.3.280
1.3.270
1.2.270
1.2.260
1.2.250
1.2.240
1.2.230
1.2.220
1.2.210
1.2.200
1.2.190
1.2.180
1.2.170
1.2.160
1.2.150
1.2.140
1.2.130
1.2.120
1.2.110
1.2.100
1.2.90
1.1.90
1.1.80
1.1.70
1.1.60
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i @dramaorg/dolores-sunt

Weekly Downloads

5

Version

2.10.68

License

MIT

Unpacked Size

154 kB

Total Files

409

Last publish

Collaborators

  • vanthuanbt26