postcss-aspect-ratio-property
v1.0.0
Published
PostCSS plugin CSS4 aspect-ratio property
Downloads
775
Maintainers
Readme
PostCSS Aspect Ratio Property
PostCSS plugin The CSS Working Group have designed an aspect-ratio property for CSS.This plugin make this future feature available now..
.foo {
/* Input example */
aspect-ratio: 16/9;
}
.foo {
/* Output example */
position: relative;
}
.foo::before {
content: '';
display: block;
padding-top: 56.25%;
}
.foo > div {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
options
Type: Object
default:
{
mainSelector: '.box'
}
.foo {
/* Input example */
aspect-ratio: 16/9;
}
...
.foo > .box {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
Usage
Step 1: Install plugin:
npm install --save-dev postcss postcss-aspect-ratio-property
Step 2: Check you project for existed PostCSS config: postcss.config.js
in the project root, "postcss"
section in package.json
or postcss
in bundle config.
If you do not use PostCSS, add it according to official docs and set this plugin in settings.
Step 3: Add the plugin to plugins list:
module.exports = {
plugins: [
+ require('postcss-aspect-ratio-property'),
require('autoprefixer')
]
}