https://github.com/csstools/postcss-short-position
Define sides within the position property in CSS
https://github.com/csstools/postcss-short-position
Last synced: 11 months ago
JSON representation
Define sides within the position property in CSS
- Host: GitHub
- URL: https://github.com/csstools/postcss-short-position
- Owner: csstools
- License: cc0-1.0
- Archived: true
- Created: 2015-09-19T23:08:18.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-10-10T11:51:22.000Z (over 7 years ago)
- Last Synced: 2025-04-21T21:38:06.454Z (11 months ago)
- Language: JavaScript
- Homepage: https://jonathantneal.github.io/postcss-short/
- Size: 21.5 KB
- Stars: 6
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PostCSS Short Position [
][postcss]
[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Support Chat][git-img]][git-url]
[PostCSS Short Position] lets define sides within the `position` property in
CSS.
```pcss
.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:
```bash
npm install postcss-short-position --save-dev
```
Use [PostCSS Short Position] to process your CSS:
```js
const postcssShortPosition = require('postcss-short-position');
postcssShortPosition.process(YOUR_CSS /*, processOptions, pluginOptions */);
```
Or use it as a [PostCSS] plugin:
```js
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](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
| --- | --- | --- | --- | --- | --- |
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-short-position.svg
[cli-url]: https://travis-ci.org/jonathantneal/postcss-short-position
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[npm-img]: https://img.shields.io/npm/v/postcss-short-position.svg
[npm-url]: https://www.npmjs.com/package/postcss-short-position
## 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`.
```js
postcssShortPosition({ prefix: 'x' });
```
```pcss
.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.
```js
postcssShortPosition({ skip: '-' });
```
```pcss
.header {
position: fixed 0 1em -;
}
/* becomes */
.header {
top: 0;
right: 1em;
left: 1em;
position: fixed;
}
```
[1-to-4 syntax]: https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties#Tricky_edge_cases
[PostCSS]: https://github.com/postcss/postcss
[PostCSS Short Position]: https://github.com/jonathantneal/postcss-short-position