PostCSS plugin for making calculations with math.js. Works with PostCSS 5!
JavaScript
Pull request Compare This branch is 1 commit ahead, 32 commits behind shauns:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.eslintrc
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
gulpfile.js
index.js
package.json

README.md

PostCSS Math Build Status

Work-in-progress!

PostCSS plugin for making calculations with math.js.

This plug-in supports:

  • Plain-old maths, as per math.js built-in functionality
  • px units
  • CSS-friendly rendering (10cm not 10 cm)
  • Unit stripping e.g. strip(25px) becomes 25

Contributions are very welcome!

.foo {
    font-size: resolve(2 * 8px);
    padding: resolve(strip(16cm) + (2px * 3));
    margin: resolve(4px + resolve(2 * 3px));
}
.foo {
    font-size: 16px;
    padding: 22px;
    margin: 10px;
}

Usage

postcss([ require('postcss-math') ])

See PostCSS docs for examples for your environment.

How does this differ to postcss-calc?

They're (deliberately) trying to work towards the calc(...) standard, so for instance it doesn't support things like exponentials at the moment. This wraps up math.js so you have a wider range of things you can do.