css-mqpacker-starter
css-mqpacker
Mixin starter with scss forYou must use the package with scss and postcss. You will find the webpack rule for compiling scss files with css-mqpacker below or use webpack starter.
Installation
Breakpoints
Init order
Mixins
Source mixin code
Possible order error
Webpack rule for compiling
Installation
Install the package
npm i css-mqpacker-starter
Import in main scss file
;
Now use it :)
Breakpoints
The package provide default breakpoints:
Breakpoint | Pixels |
---|---|
$xl | 1200px |
$lg | 992px |
$md | 768px |
$sm | 576px |
$xs | 420px |
$xxs | 360px |
Mixins
There are media queries mixins for each breakpoint. Desktop First and Mobile First.
down | up |
---|---|
xl | xl-up |
lg | lg-up |
md | md-up |
sm | sm-up |
xs | xs-up |
xxs | xxs-up |
Init order:
Put the mixin before custom scss code. It will create placeholder styles for body tag. It's important for css-mqpacker; There can be wrong order media queries without the mixin.
Possible error see below
Source mixin code:
Possible order error
In the case:
.card .container
Output after css-mqpacker will be:
.card .container
On screen $sm and below style .container{ max-width: none; }
will not be applied.
Use @include initMediaPosition()
to prevent this error.
Webpack rule for compiling
Here is example: Webpack starter
// rules: test: /\.scss$/ use: isDev ? "style-loader" : MiniCssExtractPluginloader loader: "css-loader" options: sourceMap: true loader: "postcss-loader" options: sourceMap: true config: path: "postcss.config.js" loader: "sass-loader" options: sourceMap: true ;