包详细信息

postcss-short-spacing

jonathantneal38kCC0-1.04.0.0

Use this in CSS

postcss, css, postcss-plugin, margin

自述文件

PostCSS Short Spacing PostCSS

NPM Version Build Status Support Chat

PostCSS Short Spacing lets you omit sides within margin and padding properties in CSS.

section {
  margin: 1em *;
}

/* becomes */

section {
  margin-top: 1em;
  margin-bottom: 1em;
}

Supported properties include margin, margin-block, margin-inline, margin-start, margin-end, padding, padding-block, padding-inline, padding-start, and padding-end.

Usage

Add PostCSS Short Spacing to your project:

npm install postcss-short-spacing --save-dev

Use PostCSS Short Spacing to process your CSS:

const postcssShortSpacing = require('postcss-short-spacing');

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

Or use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssShortSpacing = require('postcss-short-spacing');

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

PostCSS Short Spacing 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-margin.

postcssShortSpacing({ prefix: 'x' });
body {
  -x-margin: 1em *;
}

/* becomes */

section {
  margin-top: 1em;
  margin-bottom: 1em;
}

skip

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

postcssShortSpacing({ skip: '-' });
body {
  -x-margin: 1em -;
}

/* becomes */

section {
  margin-top: 1em;
  margin-bottom: 1em;
}

更新日志

Changes to PostCSS Short Spacing

4.0.0 (October 9, 2018)

  • Added: Support for Node 6
  • Added: Support for PostCSS 7
  • Added: Support for logical spacing properties

3.0.0 (May 25, 2017)

  • Added: Support for PostCSS 6, Node 4
  • Removed: echint and jscs devDependencies
  • Updated: 2 spaces in Markdown
  • Updated: dependencies

2.0.1 (December 8, 2016)

  • Added: #Plugin.process for stand-alone execution and testing
  • Updated: Use destructing assignment on plugin options
  • Updated: Use template literals

2.0.0 (December 6, 2016)

  • Added: Define skip token
  • Updated: boilerplate conventions (Node v6.9.1 LTS)

1.0.0 (September 21, 2015)

  • Added: Initial version