JSPM

postcss-aspect-ratio-property

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4031
  • Score
    100M100P100Q137888F
  • License MIT

PostCSS plugin CSS4 aspect-ratio property

Package Exports

  • postcss-aspect-ratio-property

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-aspect-ratio-property) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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