1. postcss-short-position
Define sides within the position property in CSS
postcss-short-position
Package: postcss-short-position
Created by: jonathantneal
Last modified: Mon, 19 Feb 2024 21:20:55 GMT
Version: 4.0.1
License: CC0-1.0
Downloads: 9,916
Repository: https://github.com/jonathantneal/postcss-short-position

Install

npm install postcss-short-position
yarn add postcss-short-position

PostCSS Short Position PostCSS

NPM Version
Build Status
Support Chat

PostCSS Short Position lets define sides within the position property in
CSS.

.header {
  position: fixed 0 1em *;
}

/* becomes */

.header {
  top: 0;
  right: 1em;
  left: 1em;
  position: fixed;
}

The position declaration can be extended with the 1-to-4 syntax to target
top, right, bottom, and left. Sides can be omitted using the skip token.

Usage

Add PostCSS Short Position to your project:

 npm install postcss-short-position --save-dev

Use PostCSS Short Position to process your CSS:

 const postcssShortPosition = require('postcss-short-position');

postcssShortPosition.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS plugin:

 const postcss = require('postcss');
const postcssShortPosition = require('postcss-short-position');

postcss([
  postcssShortPosition(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS Short Position runs in all Node environments, with special instructions for:

Node PostCSS CLI Webpack Create React App Gulp Grunt

Options

prefix

The prefix option defines a prefix required by properties being transformed.
Wrapping dashes are automatically applied, so that x would transform
-x-position.

 postcssShortPosition({ prefix: 'x' });
.header {
  x-position: fixed 0 1em *;
}

/* becomes */

.header {
  top: 0;
  right: 1em;
  left: 1em;
  position: fixed;
}

skip

The skip option defines the skip token used to ignore portions of the
shorthand.

 postcssShortPosition({ skip: '-' });
.header {
  position: fixed 0 1em -;
}

/* becomes */

.header {
  top: 0;
  right: 1em;
  left: 1em;
  position: fixed;
}

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code