Detalhes do pacote

postcss-aspect-ratio-property

supermonkeyz1.9kMIT1.0.0

PostCSS plugin CSS4 aspect-ratio property

postcss, css, css4, postcss-plugin

readme (leia-me)

PostCSS Aspect Ratio Property Build Status circleci

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')
  ]
}

changelog (log de mudanças)

Change Log

v1.0.0

  • Base on Postcss 8