https://github.com/csstools/postcss-at-else
Use at-else inverted media queries in CSS
https://github.com/csstools/postcss-at-else
Last synced: 11 months ago
JSON representation
Use at-else inverted media queries in CSS
- Host: GitHub
- URL: https://github.com/csstools/postcss-at-else
- Owner: csstools
- License: cc0-1.0
- Created: 2016-06-12T05:06:55.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2021-11-08T10:36:13.000Z (over 4 years ago)
- Last Synced: 2024-04-14T03:59:11.497Z (almost 2 years ago)
- Language: CSS
- Homepage: http://jonathantneal.github.io/postcss-at-else/
- Size: 60.5 KB
- Stars: 11
- Watchers: 5
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Licensing][lic-image]][lic-url]
[![Changelog][log-image]][log-url]
[![Gitter Chat][git-image]][git-url]
[@else] lets you use `@else` inverted media queries in CSS.
```css
/* before */
@media (min-width: 30em) {
body {
background-color: blue;
}
} @else {
body {
background-color: yellow;
}
}
/* after */
@media (min-width: 30em) {
body {
background-color: blue;
}
} @media (max-width: 29.999em) {
body {
background-color: yellow;
}
}
```
## Usage
Add [@else] to your build tool:
```bash
npm install postcss postcss-at-else --save-dev
```
#### PostCSS
Add [PostCSS] to your build tool:
```bash
npm install postcss --save-dev
```
Load [@else] as a PostCSS plugin:
```js
postcss([
require('postcss-at-else')({ /* options */ })
]).process(YOUR_CSS, /* options */);
```
#### Gulp
Add [Gulp PostCSS] to your build tool:
```bash
npm install gulp-postcss --save-dev
```
Enable [@else] within your Gulpfile:
```js
var postcss = require('gulp-postcss');
gulp.task('css', function () {
return gulp.src('./src/*.css').pipe(
postcss([
require('postcss-at-else')({ /* options */ })
])
).pipe(
gulp.dest('.')
);
});
```
#### Grunt
Add [Grunt PostCSS] to your build tool:
```bash
npm install grunt-postcss --save-dev
```
Enable [@else] within your Gruntfile:
```js
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
postcss: {
options: {
use: [
require('postcss-at-else')({ /* options */ })
]
},
dist: {
src: '*.css'
}
}
});
```
[npm-url]: https://www.npmjs.com/package/postcss-at-else
[npm-img]: https://img.shields.io/npm/v/postcss-at-else.svg
[cli-url]: https://travis-ci.org/jonathantneal/postcss-at-else
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-at-else.svg
[lic-url]: LICENSE.md
[lic-image]: https://img.shields.io/npm/l/postcss-at-else.svg
[log-url]: CHANGELOG.md
[log-image]: https://img.shields.io/badge/changelog-md-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[git-image]: https://img.shields.io/badge/chat-gitter-blue.svg
[@else]: https://github.com/jonathantneal/postcss-at-else
[PostCSS]: https://github.com/postcss/postcss
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss