autoprefixer 9.8.8 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +990 -0
  2. package/README.md +1048 -5
  3. package/bin/autoprefixer +11 -11
  4. package/data/prefixes.js +799 -545
  5. package/lib/at-rule.js +23 -50
  6. package/lib/autoprefixer.js +107 -96
  7. package/lib/brackets.js +31 -44
  8. package/lib/browsers.js +54 -71
  9. package/lib/declaration.js +122 -178
  10. package/lib/hacks/align-content.js +24 -54
  11. package/lib/hacks/align-items.js +23 -53
  12. package/lib/hacks/align-self.js +32 -60
  13. package/lib/hacks/animation.js +11 -29
  14. package/lib/hacks/appearance.js +19 -35
  15. package/lib/hacks/backdrop-filter.js +16 -31
  16. package/lib/hacks/background-clip.js +19 -36
  17. package/lib/hacks/background-size.js +16 -31
  18. package/lib/hacks/block-logical.js +28 -36
  19. package/lib/hacks/border-image.js +9 -27
  20. package/lib/hacks/border-radius.js +22 -44
  21. package/lib/hacks/break-props.js +38 -51
  22. package/lib/hacks/color-adjust.js +11 -30
  23. package/lib/hacks/cross-fade.js +29 -48
  24. package/lib/hacks/display-flex.js +32 -61
  25. package/lib/hacks/display-grid.js +12 -32
  26. package/lib/hacks/filter-value.js +8 -25
  27. package/lib/hacks/filter.js +13 -27
  28. package/lib/hacks/flex-basis.js +21 -54
  29. package/lib/hacks/flex-direction.js +41 -77
  30. package/lib/hacks/flex-flow.js +33 -61
  31. package/lib/hacks/flex-grow.js +16 -43
  32. package/lib/hacks/flex-shrink.js +21 -54
  33. package/lib/hacks/flex-spec.js +7 -10
  34. package/lib/hacks/flex-wrap.js +11 -32
  35. package/lib/hacks/flex.js +27 -58
  36. package/lib/hacks/fullscreen.js +10 -30
  37. package/lib/hacks/gradient.js +240 -330
  38. package/lib/hacks/grid-area.js +25 -43
  39. package/lib/hacks/grid-column-align.js +14 -34
  40. package/lib/hacks/grid-end.js +30 -45
  41. package/lib/hacks/grid-row-align.js +14 -34
  42. package/lib/hacks/grid-row-column.js +20 -39
  43. package/lib/hacks/grid-rows-columns.js +75 -99
  44. package/lib/hacks/grid-start.js +17 -39
  45. package/lib/hacks/grid-template-areas.js +59 -76
  46. package/lib/hacks/grid-template.js +40 -61
  47. package/lib/hacks/grid-utils.js +681 -715
  48. package/lib/hacks/image-rendering.js +24 -47
  49. package/lib/hacks/image-set.js +10 -30
  50. package/lib/hacks/inline-logical.js +26 -32
  51. package/lib/hacks/intrinsic.js +40 -53
  52. package/lib/hacks/justify-content.js +26 -57
  53. package/lib/hacks/mask-border.js +28 -36
  54. package/lib/hacks/mask-composite.js +41 -57
  55. package/lib/hacks/order.js +22 -52
  56. package/lib/hacks/overscroll-behavior.js +16 -37
  57. package/lib/hacks/pixelated.js +16 -40
  58. package/lib/hacks/place-self.js +18 -41
  59. package/lib/hacks/placeholder-shown.js +9 -28
  60. package/lib/hacks/placeholder.js +15 -38
  61. package/lib/hacks/text-decoration-skip-ink.js +14 -29
  62. package/lib/hacks/text-decoration.js +20 -31
  63. package/lib/hacks/text-emphasis-position.js +9 -28
  64. package/lib/hacks/transform-decl.js +43 -69
  65. package/lib/hacks/user-select.js +9 -28
  66. package/lib/hacks/writing-mode.js +19 -36
  67. package/lib/info.js +63 -93
  68. package/lib/old-selector.js +39 -60
  69. package/lib/old-value.js +17 -25
  70. package/lib/prefixer.js +83 -110
  71. package/lib/prefixes.js +233 -333
  72. package/lib/processor.js +420 -416
  73. package/lib/resolution.js +62 -98
  74. package/lib/selector.js +91 -138
  75. package/lib/supports.js +194 -246
  76. package/lib/transition.js +170 -265
  77. package/lib/utils.js +52 -69
  78. package/lib/value.js +77 -116
  79. package/lib/vendor.js +14 -0
  80. package/package.json +16 -7
package/README.md CHANGED
@@ -36,9 +36,6 @@ of Autoprefixer.
36
36
  :-ms-input-placeholder {
37
37
  color: gray;
38
38
  }
39
- ::-ms-input-placeholder {
40
- color: gray;
41
- }
42
39
  ::placeholder {
43
40
  color: gray;
44
41
  }
@@ -69,5 +66,1051 @@ Twitter account for news and releases: [@autoprefixer].
69
66
  [cult]: http://cultofmartians.com/tasks/autoprefixer-grid.html
70
67
 
71
68
 
72
- ## Docs
73
- Read **[full docs](https://github.com/postcss/autoprefixer#readme)** on GitHub.
69
+ ## Contents
70
+
71
+ * [Contents](#contents)
72
+ * [Browsers](#browsers)
73
+ * [FAQ](#faq)
74
+ * [Does Autoprefixer polyfill Grid Layout for IE?](#does-autoprefixer-polyfill-grid-layout-for-ie)
75
+ * [Does it add polyfills?](#does-it-add-polyfills)
76
+ * [Why doesn’t Autoprefixer add prefixes to `border-radius`?](#why-doesnt-autoprefixer-add-prefixes-to-border-radius)
77
+ * [Why does Autoprefixer use unprefixed properties in `@-webkit-keyframes`?](#why-does-autoprefixer-use-unprefixed-properties-in--webkit-keyframes)
78
+ * [How to work with legacy `-webkit-` only code?](#how-to-work-with-legacy--webkit--only-code)
79
+ * [Does Autoprefixer add `-epub-` prefix?](#does-autoprefixer-add--epub--prefix)
80
+ * [Why doesn’t Autoprefixer transform generic font-family `system-ui`?](#why-doesnt-autoprefixer-transform-generic-font-family-system-ui)
81
+ * [Usage](#usage)
82
+ * [Gulp](#gulp)
83
+ * [Webpack](#webpack)
84
+ * [CSS-in-JS](#css-in-js)
85
+ * [CLI](#cli)
86
+ * [Other Build Tools](#other-build-tools)
87
+ * [Preprocessors](#preprocessors)
88
+ * [GUI Tools](#gui-tools)
89
+ * [JavaScript](#javascript)
90
+ * [Text Editors and IDE](#text-editors-and-ide)
91
+ * [Warnings](#warnings)
92
+ * [Disabling](#disabling)
93
+ * [Prefixes](#prefixes)
94
+ * [Features](#features)
95
+ * [Control Comments](#control-comments)
96
+ * [Options](#options)
97
+ * [Environment Variables](#environment-variables)
98
+ * [Using environment variables to support CSS Grid prefixes in Create React App](#using-environment-variables-to-support-css-grid-prefixes-in-create-react-app)
99
+ * [Grid Autoplacement support in IE](#grid-autoplacement-support-in-ie)
100
+ * [Beware of enabling autoplacement in old projects](#beware-of-enabling-autoplacement-in-old-projects)
101
+ * [Autoplacement limitations](#autoplacement-limitations)
102
+ * [Both columns and rows must be defined](#both-columns-and-rows-must-be-defined)
103
+ * [Repeat auto-fit and auto-fill are not supported](#repeat-auto-fit-and-auto-fill-are-not-supported)
104
+ * [No manual cell placement or column/row spans allowed inside an autoplacement grid](#no-manual-cell-placement-or-columnrow-spans-allowed-inside-an-autoplacement-grid)
105
+ * [Do not create `::before` and `::after` pseudo elements](#do-not-create-before-and-after-pseudo-elements)
106
+ * [When changing the `grid gap` value, columns and rows must be re-declared](#when-changing-the-grid-gap-value-columns-and-rows-must-be-re-declared)
107
+ * [Debug](#debug)
108
+ * [Security Contact](#security-contact)
109
+ * [For Enterprise](#for-enterprise)
110
+
111
+ ## Browsers
112
+
113
+ Autoprefixer uses [Browserslist], so you can specify the browsers
114
+ you want to target in your project with queries like `> 5%`
115
+ (see [Best Practices]).
116
+
117
+ The best way to provide browsers is a `.browserslistrc` file in your project
118
+ root, or by adding a `browserslist` key to your `package.json`.
119
+
120
+ We recommend the use of these options over passing options to Autoprefixer so
121
+ that the config can be shared with other tools such as [babel-preset-env] and
122
+ [Stylelint].
123
+
124
+ See [Browserslist docs] for queries, browser names, config format, and defaults.
125
+
126
+ [Browserslist docs]: https://github.com/browserslist/browserslist#queries
127
+ [babel-preset-env]: https://github.com/babel/babel/tree/master/packages/babel-preset-env
128
+ [Best Practices]: https://github.com/browserslist/browserslist#best-practices
129
+ [Browserslist]: https://github.com/browserslist/browserslist
130
+ [Stylelint]: https://stylelint.io/
131
+
132
+
133
+ ## FAQ
134
+
135
+ ### Does Autoprefixer polyfill Grid Layout for IE?
136
+
137
+ Autoprefixer can be used to translate modern CSS Grid syntax into IE 10
138
+ and IE 11 syntax, but this polyfill will not work in 100% of cases.
139
+ This is why it is disabled by default.
140
+
141
+ First, you need to enable Grid prefixes by using either the `grid: "autoplace"`
142
+ option or the `/* autoprefixer grid: autoplace */` control comment.
143
+ Also you can use environment variable to enable Grid:
144
+ `AUTOPREFIXER_GRID=autoplace npm build`.
145
+
146
+ Second, you need to test every fix with Grid in IE. It is not an enable and
147
+ forget feature, but it is still very useful.
148
+ Financial Times and Yandex use it in production.
149
+
150
+ Third, there is only very limited auto placement support. Read the
151
+ [Grid Autoplacement support in IE](#grid-autoplacement-support-in-ie) section
152
+ for more details.
153
+
154
+ Fourth, if you are not using the autoplacement feature, the best way
155
+ to use Autoprefixer is by using `grid-template` or `grid-template-areas`.
156
+
157
+ ```css
158
+ .page {
159
+ display: grid;
160
+ grid-gap: 33px;
161
+ grid-template:
162
+ "head head head" 1fr
163
+ "nav main main" minmax(100px, 1fr)
164
+ "nav foot foot" 2fr /
165
+ 1fr 100px 1fr;
166
+ }
167
+ .page__head {
168
+ grid-area: head;
169
+ }
170
+ .page__nav {
171
+ grid-area: nav;
172
+ }
173
+ .page__main {
174
+ grid-area: main;
175
+ }
176
+ .page__footer {
177
+ grid-area: foot;
178
+ }
179
+ ```
180
+
181
+ See also:
182
+
183
+ * [The guide about Grids in IE and Autoprefixer].
184
+ * [`postcss-gap-properties`] to use new `gap` property
185
+ instead of old `grid-gap`.
186
+ * [`postcss-grid-kiss`] has alternate “everything in one property” syntax,
187
+ which makes using Autoprefixer’s Grid translations safer.
188
+
189
+ [The guide about Grids in IE and Autoprefixer]: https://css-tricks.com/css-grid-in-ie-css-grid-and-the-new-autoprefixer/
190
+ [`postcss-gap-properties`]: https://github.com/jonathantneal/postcss-gap-properties
191
+ [`postcss-grid-kiss`]: https://github.com/sylvainpolletvillard/postcss-grid-kiss
192
+
193
+
194
+ ### Does it add polyfills?
195
+
196
+ No. Autoprefixer only adds prefixes.
197
+
198
+ Most new CSS features will require client side JavaScript to handle a new
199
+ behavior correctly.
200
+
201
+ Depending on what you consider to be a “polyfill”, you can take a look at some
202
+ other tools and libraries. If you are just looking for syntax sugar,
203
+ you might take a look at:
204
+
205
+ - [postcss-preset-env] is a plugins preset with polyfills and Autoprefixer
206
+ to write future CSS today.
207
+ - [Oldie], a PostCSS plugin that handles some IE hacks (opacity, rgba, etc).
208
+ - [postcss-flexbugs-fixes], a PostCSS plugin to fix flexbox issues.
209
+
210
+ [postcss-flexbugs-fixes]: https://github.com/luisrudge/postcss-flexbugs-fixes
211
+ [postcss-preset-env]: https://github.com/jonathantneal/postcss-preset-env
212
+ [Oldie]: https://github.com/jonathantneal/oldie
213
+
214
+
215
+ ### Why doesn’t Autoprefixer add prefixes to `border-radius`?
216
+
217
+ Developers are often surprised by how few prefixes are required today.
218
+ If Autoprefixer doesn’t add prefixes to your CSS, check if they’re still
219
+ required on [Can I Use].
220
+
221
+ [Can I Use]: https://caniuse.com/
222
+
223
+
224
+ ### Why does Autoprefixer use unprefixed properties in `@-webkit-keyframes`?
225
+
226
+ Browser teams can remove some prefixes before others, so we try to use all
227
+ combinations of prefixed/unprefixed values.
228
+
229
+
230
+ ### How to work with legacy `-webkit-` only code?
231
+
232
+ Autoprefixer needs unprefixed property to add prefixes. So if you only
233
+ wrote `-webkit-gradient` without W3C’s `gradient`,
234
+ Autoprefixer will not add other prefixes.
235
+
236
+ But [PostCSS] has plugins to convert CSS to unprefixed state.
237
+ Use [postcss-unprefix] before Autoprefixer.
238
+
239
+ [postcss-unprefix]: https://github.com/gucong3000/postcss-unprefix
240
+
241
+
242
+ ### Does Autoprefixer add `-epub-` prefix?
243
+
244
+ No, Autoprefixer works only with browsers prefixes from Can I Use.
245
+ But you can use [postcss-epub] for prefixing ePub3 properties.
246
+
247
+ [postcss-epub]: https://github.com/Rycochet/postcss-epub
248
+
249
+
250
+ ### Why doesn’t Autoprefixer transform generic font-family `system-ui`?
251
+
252
+ `system-ui` is technically not a prefix and the transformation is not
253
+ future-proof. You can use [postcss-font-family-system-ui] to transform
254
+ `system-ui` to a practical font-family list.
255
+
256
+ [postcss-font-family-system-ui]: https://github.com/JLHwung/postcss-font-family-system-ui
257
+
258
+
259
+ ## Usage
260
+
261
+ ### Gulp
262
+
263
+ In Gulp you can use [gulp-postcss] with `autoprefixer` npm package.
264
+
265
+ ```js
266
+ gulp.task('autoprefixer', () => {
267
+ const autoprefixer = require('autoprefixer')
268
+ const sourcemaps = require('gulp-sourcemaps')
269
+ const postcss = require('gulp-postcss')
270
+
271
+ return gulp.src('./src/*.css')
272
+ .pipe(sourcemaps.init())
273
+ .pipe(postcss([ autoprefixer() ]))
274
+ .pipe(sourcemaps.write('.'))
275
+ .pipe(gulp.dest('./dest'))
276
+ })
277
+ ```
278
+
279
+ With `gulp-postcss` you also can combine Autoprefixer
280
+ with [other PostCSS plugins].
281
+
282
+ [gulp-postcss]: https://github.com/postcss/gulp-postcss
283
+ [other PostCSS plugins]: https://github.com/postcss/postcss#plugins
284
+
285
+
286
+ ### Webpack
287
+
288
+ In [webpack] you can use [postcss-loader] with `autoprefixer`
289
+ and [other PostCSS plugins].
290
+
291
+ ```js
292
+ module.exports = {
293
+ module: {
294
+ rules: [
295
+ {
296
+ test: /\.css$/,
297
+ use: ["style-loader", "css-loader", "postcss-loader"]
298
+ }
299
+ ]
300
+ }
301
+ }
302
+ ```
303
+
304
+ And create a `postcss.config.js` with:
305
+
306
+ ```js
307
+ module.exports = {
308
+ plugins: [
309
+ require('autoprefixer')
310
+ ]
311
+ }
312
+ ```
313
+
314
+ [other PostCSS plugins]: https://github.com/postcss/postcss#plugins
315
+ [postcss-loader]: https://github.com/postcss/postcss-loader
316
+ [webpack]: https://webpack.js.org/
317
+
318
+
319
+ ### CSS-in-JS
320
+
321
+ The best way to use PostCSS with CSS-in-JS is [`astroturf`].
322
+ Add its loader to your `webpack.config.js`:
323
+
324
+ ```js
325
+ module.exports = {
326
+ module: {
327
+ rules: [
328
+ {
329
+ test: /\.css$/,
330
+ use: ['style-loader', 'postcss-loader'],
331
+ },
332
+ {
333
+ test: /\.jsx?$/,
334
+ use: ['babel-loader', 'astroturf/loader'],
335
+ }
336
+ ]
337
+ }
338
+ }
339
+ ```
340
+
341
+ Then create `postcss.config.js`:
342
+
343
+ ```js
344
+ module.exports = {
345
+ plugins: [
346
+ require('autoprefixer')
347
+ ]
348
+ }
349
+ ```
350
+
351
+ [`astroturf`]: https://github.com/4Catalyzer/astroturf
352
+
353
+
354
+ ### CLI
355
+
356
+ You can use the [postcss-cli] to run Autoprefixer from CLI:
357
+
358
+ ```sh
359
+ npm install postcss-cli autoprefixer
360
+ npx postcss *.css --use autoprefixer -d build/
361
+ ```
362
+
363
+ See `postcss -h` for help.
364
+
365
+ [postcss-cli]: https://github.com/postcss/postcss-cli
366
+
367
+
368
+ ### Other Build Tools
369
+
370
+ * **Grunt:** [grunt-postcss]
371
+ * **Ruby on Rails**: [autoprefixer-rails]
372
+ * **Neutrino**: [neutrino-middleware-postcss]
373
+ * **Jekyll**: add `autoprefixer-rails` and `jekyll-assets` to `Gemfile`
374
+ * **Brunch**: [postcss-brunch]
375
+ * **Broccoli**: [broccoli-postcss]
376
+ * **Middleman**: [middleman-autoprefixer]
377
+ * **Mincer**: add `autoprefixer` npm package and enable it:
378
+ `environment.enable('autoprefixer')`
379
+
380
+ [neutrino-middleware-postcss]: https://www.npmjs.com/package/neutrino-middleware-postcss
381
+ [middleman-autoprefixer]: https://github.com/middleman/middleman-autoprefixer
382
+ [autoprefixer-rails]: https://github.com/ai/autoprefixer-rails
383
+ [broccoli-postcss]: https://github.com/jeffjewiss/broccoli-postcss
384
+ [postcss-brunch]: https://github.com/iamvdo/postcss-brunch
385
+ [grunt-postcss]: https://github.com/C-Lodder/grunt-postcss
386
+
387
+
388
+ #### Preprocessors
389
+
390
+ * **Less**: [less-plugin-autoprefix]
391
+ * **Stylus**: [autoprefixer-stylus]
392
+ * **Compass**: [autoprefixer-rails#compass]
393
+
394
+ [less-plugin-autoprefix]: https://github.com/less/less-plugin-autoprefix
395
+ [autoprefixer-stylus]: https://github.com/jenius/autoprefixer-stylus
396
+ [autoprefixer-rails#compass]: https://github.com/ai/autoprefixer-rails#compass
397
+
398
+
399
+ #### GUI Tools
400
+
401
+ * [CodeKit](https://codekitapp.com/help/autoprefixer/)
402
+ * [Prepros](https://prepros.io)
403
+
404
+
405
+ ### JavaScript
406
+
407
+ You can use Autoprefixer with [PostCSS] in your Node.js application
408
+ or if you want to develop an Autoprefixer plugin for a new environment.
409
+
410
+ ```js
411
+ const autoprefixer = require('autoprefixer')
412
+ const postcss = require('postcss')
413
+
414
+ postcss([ autoprefixer ]).process(css).then(result => {
415
+ result.warnings().forEach(warn => {
416
+ console.warn(warn.toString())
417
+ })
418
+ console.log(result.css)
419
+ })
420
+ ```
421
+
422
+ There is also a [standalone build] for the browser or for a non-Node.js runtime.
423
+
424
+ You can use [html-autoprefixer] to process HTML with inlined CSS.
425
+
426
+ [html-autoprefixer]: https://github.com/RebelMail/html-autoprefixer
427
+ [standalone build]: https://raw.github.com/ai/autoprefixer-rails/master/vendor/autoprefixer.js
428
+ [PostCSS]: https://github.com/postcss/postcss
429
+
430
+
431
+ ### Text Editors and IDE
432
+
433
+ Autoprefixer should be used in assets build tools. Text editor plugins are not
434
+ a good solution, because prefixes decrease code readability and you will need
435
+ to change values in all prefixed properties.
436
+
437
+ I recommend you to learn how to use build tools like [Parcel].
438
+ They work much better and will open you a whole new world of useful plugins
439
+ and automation.
440
+
441
+ If you can’t move to a build tool, you can use text editor plugins:
442
+
443
+ * [Visual Studio Code](https://github.com/mrmlnc/vscode-autoprefixer)
444
+ * [Atom Editor](https://github.com/sindresorhus/atom-autoprefixer)
445
+ * [Sublime Text](https://github.com/sindresorhus/sublime-autoprefixer)
446
+ * [Brackets](https://github.com/mikaeljorhult/brackets-autoprefixer)
447
+
448
+ [Parcel]: https://parceljs.org/
449
+
450
+
451
+ ## Warnings
452
+
453
+ Autoprefixer uses the [PostCSS warning API] to warn about really important
454
+ problems in your CSS:
455
+
456
+ * Old direction syntax in gradients.
457
+ * Old unprefixed `display: box` instead of `display: flex`
458
+ by latest specification version.
459
+
460
+ You can get warnings from `result.warnings()`:
461
+
462
+ ```js
463
+ result.warnings().forEach(warn => {
464
+ console.warn(warn.toString())
465
+ })
466
+ ```
467
+
468
+ Every Autoprefixer runner should display these warnings.
469
+
470
+ [PostCSS warning API]: http://api.postcss.org/Warning.html
471
+
472
+
473
+ ## Disabling
474
+
475
+ ### Prefixes
476
+
477
+ Autoprefixer was designed to have no interface – it just works.
478
+ If you need some browser specific hack just write a prefixed property
479
+ after the unprefixed one.
480
+
481
+ ```css
482
+ a {
483
+ transform: scale(0.5);
484
+ -moz-transform: scale(0.6);
485
+ }
486
+ ```
487
+
488
+ If some prefixes were generated incorrectly, please create an [issue on GitHub].
489
+
490
+ [issue on GitHub]: https://github.com/postcss/autoprefixer/issues
491
+
492
+
493
+ ### Features
494
+
495
+ You can use these plugin options to control some of Autoprefixer’s features.
496
+
497
+ * `grid: "autoplace"` will enable `-ms-` prefixes for Grid Layout including some
498
+ [limited autoplacement support](#grid-autoplacement-support-in-ie).
499
+ * `supports: false` will disable `@supports` parameters prefixing.
500
+ * `flexbox: false` will disable flexbox properties prefixing.
501
+ Or `flexbox: "no-2009"` will add prefixes only for final and IE
502
+ versions of specification.
503
+ * `remove: false` will disable cleaning outdated prefixes.
504
+
505
+ You should set them inside the plugin like so:
506
+
507
+ ```js
508
+ autoprefixer({ grid: 'autoplace' })
509
+ ```
510
+
511
+
512
+ ### Control Comments
513
+
514
+ If you do not need Autoprefixer in some part of your CSS,
515
+ you can use control comments to disable Autoprefixer.
516
+
517
+ ```css
518
+ .a {
519
+ transition: 1s; /* will be prefixed */
520
+ }
521
+
522
+ .b {
523
+ /* autoprefixer: off */
524
+ transition: 1s; /* will not be prefixed */
525
+ }
526
+
527
+ .c {
528
+ /* autoprefixer: ignore next */
529
+ transition: 1s; /* will not be prefixed */
530
+ mask: url(image.png); /* will be prefixed */
531
+ }
532
+ ```
533
+
534
+ There are three types of control comments:
535
+
536
+ * `/* autoprefixer: (on|off) */`: enable/disable all Autoprefixer translations for the
537
+ whole block both *before* and *after* the comment.
538
+ * `/* autoprefixer: ignore next */`: disable Autoprefixer only for the next property
539
+ or next rule selector or at-rule parameters (but not rule/at‑rule body).
540
+ * `/* autoprefixer grid: (autoplace|no-autoplace|off) */`: control how Autoprefixer handles
541
+ grid translations for the whole block:
542
+ * `autoplace`: enable grid translations with autoplacement support.
543
+ * `no-autoplace`: enable grid translations with autoplacement
544
+ support *disabled* (alias for deprecated value `on`).
545
+ * `off`: disable all grid translations.
546
+
547
+ You can also use comments recursively:
548
+
549
+ ```css
550
+ /* autoprefixer: off */
551
+ @supports (transition: all) {
552
+ /* autoprefixer: on */
553
+ a {
554
+ /* autoprefixer: off */
555
+ }
556
+ }
557
+ ```
558
+
559
+ Note that comments that disable the whole block should not be featured in the same
560
+ block twice:
561
+
562
+ ```css
563
+ /* How not to use block level control comments */
564
+
565
+ .do-not-do-this {
566
+ /* autoprefixer: off */
567
+ transition: 1s;
568
+ /* autoprefixer: on */
569
+ transform: rotate(20deg);
570
+ }
571
+ ```
572
+
573
+
574
+ ## Options
575
+
576
+ Function `autoprefixer(options)` returns a new PostCSS plugin.
577
+ See [PostCSS API] for plugin usage documentation.
578
+
579
+ ```js
580
+ autoprefixer({ cascade: false })
581
+ ```
582
+
583
+ Available options are:
584
+
585
+ * `env` (string): environment for Browserslist.
586
+ * `cascade` (boolean): should Autoprefixer use Visual Cascade,
587
+ if CSS is uncompressed. Default: `true`
588
+ * `add` (boolean): should Autoprefixer add prefixes. Default is `true`.
589
+ * `remove` (boolean): should Autoprefixer [remove outdated] prefixes.
590
+ Default is `true`.
591
+ * `supports` (boolean): should Autoprefixer add prefixes for `@supports`
592
+ parameters. Default is `true`.
593
+ * `flexbox` (boolean|string): should Autoprefixer add prefixes for flexbox
594
+ properties. With `"no-2009"` value Autoprefixer will add prefixes only
595
+ for final and IE 10 versions of specification. Default is `true`.
596
+ * `grid` (false|`"autoplace"`|`"no-autoplace"`): should Autoprefixer
597
+ add IE 10-11 prefixes for Grid Layout properties?
598
+ * `false` (default): prevent Autoprefixer from outputting
599
+ CSS Grid translations.
600
+ * `"autoplace"`: enable Autoprefixer grid translations
601
+ and *include* autoplacement support. You can also use
602
+ `/* autoprefixer grid: autoplace */` in your CSS.
603
+ * `"no-autoplace"`: enable Autoprefixer grid translations
604
+ but *exclude* autoplacement support. You can also use
605
+ `/* autoprefixer grid: no-autoplace */` in your CSS.
606
+ (alias for the deprecated `true` value)
607
+ * `stats` (object): custom [usage statistics] for `> 10% in my stats`
608
+ browsers query.
609
+ * `overrideBrowserslist` (array): list of queries for target browsers.
610
+ Try to not use it. The best practice is to use `.browserslistrc` config
611
+ or `browserslist` key in `package.json` to share target browsers
612
+ with Babel, ESLint and Stylelint. See [Browserslist docs]
613
+ for available queries and default value.
614
+ * `ignoreUnknownVersions` (boolean): do not raise error on unknown browser
615
+ version in Browserslist config. Default is `false`.
616
+
617
+ Plugin object has `info()` method for debugging purpose.
618
+
619
+ You can use PostCSS processor to process several CSS files
620
+ to increase performance.
621
+
622
+ [usage statistics]: https://github.com/browserslist/browserslist#custom-usage-data
623
+ [PostCSS API]: http://api.postcss.org
624
+
625
+ ## Environment Variables
626
+
627
+ * `AUTOPREFIXER_GRID`: (`autoplace`|`no-autoplace`) should Autoprefixer
628
+ add IE 10-11 prefixes for Grid Layout properties?
629
+ * `autoplace`: enable Autoprefixer grid translations
630
+ and *include* autoplacement support.
631
+ * `no-autoplace`: enable Autoprefixer grid translations
632
+ but *exclude* autoplacement support.
633
+
634
+ Environment variables are useful, when you want to change Autoprefixer options but don't have access to config files.
635
+ [Create React App] is a good example of this.
636
+
637
+ [Create React App]: (https://reactjs.org/docs/create-a-new-react-app.html#create-react-app)
638
+
639
+ ### Using environment variables to support CSS Grid prefixes in Create React App
640
+
641
+ 1. Install the latest version of Autoprefixer and [cross-env](https://www.npmjs.com/package/cross-env):
642
+
643
+ ```
644
+ npm install autoprefixer@latest cross-env --save-dev
645
+ ```
646
+
647
+ 2. Under `"browserslist"` > `"development"` in the package.json file, add `"last 1 ie version"`
648
+
649
+ ```
650
+ "browserslist": {
651
+ "production": [
652
+ ">0.2%",
653
+ "not dead",
654
+ "not op_mini all"
655
+ ],
656
+ "development": [
657
+ "last 1 chrome version",
658
+ "last 1 firefox version",
659
+ "last 1 safari version",
660
+ "last 1 ie version"
661
+ ]
662
+ }
663
+ ```
664
+
665
+ 3. Update `"scripts"` in the package.json file to the following:
666
+
667
+ ```
668
+ "scripts": {
669
+ "start": "cross-env AUTOPREFIXER_GRID=autoplace react-scripts start",
670
+ "build": "cross-env AUTOPREFIXER_GRID=autoplace react-scripts build",
671
+ "test": "cross-env AUTOPREFIXER_GRID=autoplace react-scripts test",
672
+ "eject": "react-scripts eject"
673
+ },
674
+ ```
675
+
676
+ Replace `autoplace` with `no-autoplace` in the above example if you prefer to disable Autoprefixer Grid autoplacement support.
677
+
678
+ Now when you run `npm start` you will see CSS Grid prefixes automatically being applied to your output CSS.
679
+
680
+ See also [Browserslist environment variables] for more examples on how to use environment variables in your project.
681
+
682
+ [Browserslist environment variables]: https://github.com/browserslist/browserslist#environment-variables
683
+
684
+ ## Grid Autoplacement support in IE
685
+
686
+ If the `grid` option is set to `"autoplace"`, limited autoplacement support is added to Autoprefixers grid translations. You can also use
687
+ the `/* autoprefixer grid: autoplace */` control comment or
688
+ `AUTOPREFIXER_GRID=autoplace npm build` environment variable.
689
+
690
+ Autoprefixer will only autoplace grid cells if both `grid-template-rows`
691
+ and `grid-template-columns` has been set. If `grid-template`
692
+ or `grid-template-areas` has been set, Autoprefixer will use area based
693
+ cell placement instead.
694
+
695
+ Autoprefixer supports autoplacement by using `nth-child` CSS selectors.
696
+ It creates [number of columns] x [number of rows] `nth-child` selectors.
697
+ For this reason Autoplacement is only supported within the explicit grid.
698
+
699
+ ```css
700
+ /* Input CSS */
701
+
702
+ /* autoprefixer grid: autoplace */
703
+
704
+ .autoplacement-example {
705
+ display: grid;
706
+ grid-template-columns: 1fr 1fr;
707
+ grid-template-rows: auto auto;
708
+ grid-gap: 20px;
709
+ }
710
+ ```
711
+
712
+ ```css
713
+ /* Output CSS */
714
+
715
+ /* autoprefixer grid: autoplace */
716
+
717
+ .autoplacement-example {
718
+ display: -ms-grid;
719
+ display: grid;
720
+ -ms-grid-columns: 1fr 20px 1fr;
721
+ grid-template-columns: 1fr 1fr;
722
+ -ms-grid-rows: auto 20px auto;
723
+ grid-template-rows: auto auto;
724
+ grid-gap: 20px;
725
+ }
726
+
727
+ .autoplacement-example > *:nth-child(1) {
728
+ -ms-grid-row: 1;
729
+ -ms-grid-column: 1;
730
+ }
731
+
732
+ .autoplacement-example > *:nth-child(2) {
733
+ -ms-grid-row: 1;
734
+ -ms-grid-column: 3;
735
+ }
736
+
737
+ .autoplacement-example > *:nth-child(3) {
738
+ -ms-grid-row: 3;
739
+ -ms-grid-column: 1;
740
+ }
741
+
742
+ .autoplacement-example > *:nth-child(4) {
743
+ -ms-grid-row: 3;
744
+ -ms-grid-column: 3;
745
+ }
746
+ ```
747
+
748
+ ### Beware of enabling autoplacement in old projects
749
+
750
+ Be careful about enabling autoplacement in any already established projects that have
751
+ previously not used Autoprefixer's grid autoplacement feature before.
752
+
753
+ If this was your html:
754
+
755
+ ```html
756
+ <div class="grid">
757
+ <div class="grid-cell"></div>
758
+ </div>
759
+ ```
760
+
761
+ The following CSS will not work as expected with the autoplacement feature enabled:
762
+
763
+ ```css
764
+ /* Unsafe CSS when Autoplacement is enabled */
765
+
766
+ .grid-cell {
767
+ grid-column: 2;
768
+ grid-row: 2;
769
+ }
770
+
771
+ .grid {
772
+ display: grid;
773
+ grid-template-columns: repeat(3, 1fr);
774
+ grid-template-rows: repeat(3, 1fr);
775
+ }
776
+ ```
777
+
778
+ Swapping the rules around will not fix the issue either:
779
+
780
+ ```css
781
+ /* Also unsafe to use this CSS */
782
+
783
+ .grid {
784
+ display: grid;
785
+ grid-template-columns: repeat(3, 1fr);
786
+ grid-template-rows: repeat(3, 1fr);
787
+ }
788
+
789
+ .grid-cell {
790
+ grid-column: 2;
791
+ grid-row: 2;
792
+ }
793
+ ```
794
+
795
+ One way to deal with this issue is to disable autoplacement in the
796
+ grid-declaration rule:
797
+
798
+ ```css
799
+ /* Disable autoplacement to fix the issue */
800
+
801
+ .grid {
802
+ /* autoprefixer grid: no-autoplace */
803
+ display: grid;
804
+ grid-template-columns: repeat(3, 1fr);
805
+ grid-template-rows: repeat(3, 1fr);
806
+ }
807
+
808
+ .grid-cell {
809
+ grid-column: 2;
810
+ grid-row: 2;
811
+ }
812
+ ```
813
+
814
+ The absolute best way to integrate autoplacement into already existing projects
815
+ though is to leave autoplacement turned off by default and then use a control
816
+ comment to enable it when needed. This method is far less likely to cause
817
+ something on the site to break.
818
+
819
+ ```css
820
+ /* Disable autoplacement by default in old projects */
821
+ /* autoprefixer grid: no-autoplace */
822
+
823
+ /* Old code will function the same way it always has */
824
+ .old-grid {
825
+ display: grid;
826
+ grid-template-columns: repeat(3, 1fr);
827
+ grid-template-rows: repeat(3, 1fr);
828
+ }
829
+ .old-grid-cell {
830
+ grid-column: 2;
831
+ grid-row: 2;
832
+ }
833
+
834
+ /* Enable autoplacement when you want to use it in new code */
835
+ .new-autoplace-friendly-grid {
836
+ /* autoprefixer grid: autoplace */
837
+ display: grid;
838
+ grid-template-columns: repeat(3, 1fr);
839
+ grid-template-rows: repeat(3, auto);
840
+ }
841
+ ```
842
+
843
+ Note that the `grid: "no-autoplace"` setting and the
844
+ `/* autoprefixer grid: no-autoplace */` control comment share identical
845
+ functionality to the `grid: true` setting and the `/* autoprefixer grid: on */`
846
+ control comment. There is no need to refactor old code to use `no-autoplace`
847
+ in place of the old `true` and `on` statements.
848
+
849
+ ### Autoplacement limitations
850
+
851
+ #### Both columns and rows must be defined
852
+
853
+ Autoplacement only works inside the explicit grid. The columns and rows need to be defined
854
+ so that Autoprefixer knows how many `nth-child` selectors to generate.
855
+
856
+ ```css
857
+ .not-allowed {
858
+ display: grid;
859
+ grid-template-columns: repeat(3, 1fr);
860
+ }
861
+
862
+ .is-allowed {
863
+ display: grid;
864
+ grid-template-columns: repeat(3, 1fr);
865
+ grid-template-rows: repeat(10, auto);
866
+ }
867
+ ```
868
+
869
+ #### Repeat auto-fit and auto-fill are not supported
870
+
871
+ The `repeat(auto-fit, ...)` and `repeat(auto-fill, ...)` grid functionality relies on
872
+ knowledge from the browser about screen dimensions and the number of available grid
873
+ items for it to work properly. Autoprefixer does not have access to this information
874
+ so unfortunately this little snippet will _never_ be IE friendly.
875
+
876
+ ```css
877
+ .grid {
878
+ /* This will never be IE friendly */
879
+ grid-template-columns: repeat(auto-fit, min-max(200px, 1fr))
880
+ }
881
+ ```
882
+
883
+ #### No manual cell placement or column/row spans allowed inside an autoplacement grid
884
+
885
+ Elements must not be manually placed or given column/row spans inside
886
+ an autoplacement grid. Only the most basic of autoplacement grids are supported.
887
+ Grid cells can still be placed manually outside the the explicit grid though.
888
+ Support for manually placing individual grid cells inside an explicit
889
+ autoplacement grid is planned for a future release.
890
+
891
+ ```css
892
+ .autoplacement-grid {
893
+ display: grid;
894
+ grid-template-columns: repeat(3, 1fr);
895
+ grid-template-rows: repeat(3, auto);
896
+ }
897
+
898
+ /* Grid cells placed inside the explicit grid
899
+ will break the layout in IE */
900
+ .not-permitted-grid-cell {
901
+ grid-column: 1;
902
+ grid-row: 1;
903
+ }
904
+
905
+ /* Grid cells placed outside the
906
+ explicit grid will work in IE */
907
+ .permitted-grid-cell {
908
+ grid-column: 1 / span 2;
909
+ grid-row: 4;
910
+ }
911
+ ```
912
+
913
+ If manual cell placement is required, we recommend using `grid-template` or
914
+ `grid-template-areas` instead:
915
+
916
+ ```css
917
+ .page {
918
+ display: grid;
919
+ grid-gap: 30px;
920
+ grid-template:
921
+ "head head"
922
+ "nav main" minmax(100px, 1fr)
923
+ "foot foot" /
924
+ 200px 1fr;
925
+ }
926
+ .page__head {
927
+ grid-area: head;
928
+ }
929
+ .page__nav {
930
+ grid-area: nav;
931
+ }
932
+ .page__main {
933
+ grid-area: main;
934
+ }
935
+ .page__footer {
936
+ grid-area: foot;
937
+ }
938
+ ```
939
+
940
+ #### Do not create `::before` and `::after` pseudo elements
941
+
942
+ Let's say you have this HTML:
943
+
944
+ ```html
945
+ <div class="grid">
946
+ <div class="grid-cell"></div>
947
+ </div>
948
+ ```
949
+
950
+ And you write this CSS:
951
+
952
+ ```css
953
+ .grid {
954
+ display: grid;
955
+ grid-template-columns: 1fr 1fr;
956
+ grid-template-rows: auto;
957
+ }
958
+
959
+ .grid::before {
960
+ content: 'before';
961
+ }
962
+
963
+ .grid::after {
964
+ content: 'after';
965
+ }
966
+ ```
967
+
968
+ This will be the output:
969
+
970
+ ```css
971
+ .grid {
972
+ display: -ms-grid;
973
+ display: grid;
974
+ -ms-grid-columns: 1fr 1fr;
975
+ grid-template-columns: 1fr 1fr;
976
+ -ms-grid-rows: auto;
977
+ grid-template-rows: auto;
978
+ }
979
+
980
+ .grid > *:nth-child(1) {
981
+ -ms-grid-row: 1;
982
+ -ms-grid-column: 1;
983
+ }
984
+
985
+
986
+ .grid > *:nth-child(2) {
987
+ -ms-grid-row: 1;
988
+ -ms-grid-column: 2;
989
+ }
990
+
991
+ .grid::before {
992
+ content: 'before';
993
+ }
994
+
995
+ .grid::after {
996
+ content: 'after';
997
+ }
998
+ ```
999
+
1000
+ IE will place `.grid-cell`, `::before` and `::after` in row 1 column 1.
1001
+ Modern browsers on the other hand will place `::before` in row 1 column 1,
1002
+ `.grid-cell` in row 1 column 2, and `::after` in row 2 column 1.
1003
+
1004
+ See this [Code Pen](https://codepen.io/daniel-tonon/pen/gBymVw) to see a visualization
1005
+ of the issue. View the Code Pen in both a modern browser and IE to see the difference.
1006
+
1007
+ Note that you can still create `::before` and `::after` elements as long as you manually
1008
+ place them outside the explicit grid.
1009
+
1010
+ #### When changing the `grid gap` value, columns and rows must be re-declared
1011
+
1012
+ If you wish to change the size of a `grid-gap`, you will need to redeclare the grid columns and rows.
1013
+
1014
+ ```css
1015
+ .grid {
1016
+ display: grid;
1017
+ grid-template-columns: 1fr 1fr;
1018
+ grid-template-rows: auto;
1019
+ grid-gap: 50px;
1020
+ }
1021
+
1022
+ /* This will *NOT* work in IE */
1023
+ @media (max-width: 600px) {
1024
+ .grid {
1025
+ grid-gap: 20px;
1026
+ }
1027
+ }
1028
+
1029
+ /* This will *NOT* work in IE */
1030
+ .grid.small-gap {
1031
+ grid-gap: 20px;
1032
+ }
1033
+ ```
1034
+
1035
+ ```css
1036
+ .grid {
1037
+ display: grid;
1038
+ grid-template-columns: 1fr 1fr;
1039
+ grid-template-rows: auto;
1040
+ grid-gap: 50px;
1041
+ }
1042
+
1043
+ /* This *WILL* work in IE */
1044
+ @media (max-width: 600px) {
1045
+ .grid {
1046
+ grid-template-columns: 1fr 1fr;
1047
+ grid-template-rows: auto;
1048
+ grid-gap: 20px;
1049
+ }
1050
+ }
1051
+
1052
+ /* This *WILL* work in IE */
1053
+ .grid.small-gap {
1054
+ grid-template-columns: 1fr 1fr;
1055
+ grid-template-rows: auto;
1056
+ grid-gap: 20px;
1057
+ }
1058
+ ```
1059
+
1060
+ ## Debug
1061
+
1062
+ Run `npx autoprefixer --info` in your project directory to check
1063
+ which browsers are selected and which properties will be prefixed:
1064
+
1065
+ ```
1066
+ $ npx autoprefixer --info
1067
+ Browsers:
1068
+ Edge: 16
1069
+
1070
+ These browsers account for 0.26% of all users globally
1071
+
1072
+ At-Rules:
1073
+ @viewport: ms
1074
+
1075
+ Selectors:
1076
+ ::placeholder: ms
1077
+
1078
+ Properties:
1079
+ appearance: webkit
1080
+ flow-from: ms
1081
+ flow-into: ms
1082
+ hyphens: ms
1083
+ overscroll-behavior: ms
1084
+ region-fragment: ms
1085
+ scroll-snap-coordinate: ms
1086
+ scroll-snap-destination: ms
1087
+ scroll-snap-points-x: ms
1088
+ scroll-snap-points-y: ms
1089
+ scroll-snap-type: ms
1090
+ text-size-adjust: ms
1091
+ text-spacing: ms
1092
+ user-select: ms
1093
+ ```
1094
+
1095
+ JS API is also available:
1096
+
1097
+ ```js
1098
+ console.log(autoprefixer().info())
1099
+ ```
1100
+
1101
+ ## Security Contact
1102
+
1103
+ To report a security vulnerability, please use the [Tidelift security contact].
1104
+ Tidelift will coordinate the fix and disclosure.
1105
+
1106
+ [Tidelift security contact]: https://tidelift.com/security
1107
+
1108
+ ## For Enterprise
1109
+
1110
+ Available as part of the Tidelift Subscription.
1111
+
1112
+ The maintainers of `autoprefixer` and thousands of other packages are working
1113
+ with Tidelift to deliver commercial support and maintenance for the open source
1114
+ dependencies you use to build your applications. Save time, reduce risk,
1115
+ and improve code health, while paying the maintainers of the exact dependencies
1116
+ you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-autoprefixer?utm_source=npm-autoprefixer&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)