https://github.com/csstools/postcss-short-size
Use size properties in CSS
https://github.com/csstools/postcss-short-size
Last synced: 11 months ago
JSON representation
Use size properties in CSS
- Host: GitHub
- URL: https://github.com/csstools/postcss-short-size
- Owner: csstools
- License: cc0-1.0
- Archived: true
- Created: 2015-09-21T03:04:02.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-10-10T03:24:40.000Z (over 7 years ago)
- Last Synced: 2025-04-21T21:40:07.023Z (11 months ago)
- Language: JavaScript
- Homepage: https://jonathantneal.github.io/postcss-short/
- Size: 23.4 KB
- Stars: 20
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PostCSS Short Size [
][postcss]
[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Support Chat][git-img]][git-url]
[PostCSS Short Size] lets you use `size` properties to represent `width` and
`height` in CSS, following the [1-to-2 syntax].
```pcss
.image {
size: 100px;
}
.video {
max-size: 400px 300px;
}
/* becomes */
.image {
width: 100px;
height: 100px;
}
.video {
max-width: 400px;
max-height: 300px;
}
```
The supported properties are `size`, `min-size`, and `max-size`.
## Usage
Add [PostCSS Short Size] to your project:
```bash
npm install postcss-short-size --save-dev
```
Use [PostCSS Short Size] to process your CSS:
```js
const postcssShortSize = require('postcss-short-size');
postcssShortSize.process(YOUR_CSS /*, processOptions, pluginOptions */);
```
Or use it as a [PostCSS] plugin:
```js
const postcss = require('postcss');
const postcssShortSize = require('postcss-short-size');
postcss([
postcssShortSize(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```
[PostCSS Short Size] 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) |
| --- | --- | --- | --- | --- | --- |
## 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`.
```js
postcssShortSize({ prefix: 'x' });
```
```pcss
.image {
x-size: 100px;
}
/* becomes */
.image {
width: 100px;
height: 100px;
}
```
#### skip
The `skip` option defines the skip token used to ignore portions of the
shorthand.
```js
postcssShortSize({ skip: '-' });
```
```pcss
.image {
size: - 100px;
}
/* becomes */
.image {
height: 100px;
}
```
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-short-size.svg
[cli-url]: https://travis-ci.org/jonathantneal/postcss-short-size
[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-size.svg
[npm-url]: https://www.npmjs.com/package/postcss-short-size
[1-to-2 syntax]: https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties#Tricky_edge_cases
[PostCSS]: https://github.com/postcss/postcss
[PostCSS Short Size]: https://github.com/jonathantneal/postcss-short-size