Setup
1.1 PostCSS
1.2 postcss-positioning
2 Options
postcss-positioning
is a plugin for PostCSS, a CSS post-processing tool, that you probably already use for autoprefixer. If not, you can find instructions on how to setup PostCSS for your environment in its repository.
First, install postcss-positioning and its peerDependency.
npm install --save-dev postcss-positioning postcss-calc
Then, add them as a plugin to your PostCSS setup. For example, if you are using Webpack, your .postcss.config.js
could look like:
module.exports = {
plugins: [
require('postcss-positioning')({ /* options */ }),
require('postcss-calc')
]
}
Note that postcss-calc has to run after postcss-positioning.
Note: dev
and warn
options are currently unimplemented
false
,'minimal'
or'full'
. Default is'minimal'
Prepend a CSS reset. Without the reset, default margins and padding might alter the positioning.
-
false
: Don't prepend anything -
'minimal'
: Reset margin, padding and borders -
'full'
: Prepend a full CSS reset
Boolean. Default is
false
Visualize how all elements are positioned on the page, to debug or showcase your work.
String.
'all'
,'same'
or'none'
. Default is'same'
Warn when using properties that may interfere with postcss-positioning, like width
, height
, position
, margin
...
-
'all'
: always warn -
'same'
: only warn whenhorizontal
orvertical
are used on the same element -
'none'
orfalse
: never warn