Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use the parts of normalize.css (or sanitize.css) you need from your browserslist

License

NotificationsYou must be signed in to change notification settings

csstools/postcss-normalize

npm versionbuild statussupport chat

PostCSS Normalize lets you use the parts ofnormalize.css orsanitize.cssthat you need from yourbrowserslist.

@import"normalize.css";
@import"sanitize.css";

PostCSS Normalize uses a non-opinionated version ofnormalize.css, butan opinionated version may also be used.

@import"normalize.css/opinionated.css";

Examples

Here is a sample of whatnormalize.css looks like when thebrowserslistisie >= 9:

/** * Add the correct display in IE 9-. */audio,video {display: inline-block;}/** * Remove the border on images inside links in IE 10-. */img {border-style: none;}

And here is the same sample when thebrowserslist isie >= 10:

/** * Remove the border on images inside links in IE 10-. */img {border-style: none;}

Usage

AddPostCSS Normalize to your project:

npm install postcss-normalize --save-dev

Add abrowserslist entry inpackage.json:

{"browserslist":"last 2 versions"}

UsePostCSS Normalize to process your CSS:

constpostcssNormalize=require('postcss-normalize')postcssNormalize.process(YOUR_CSS/*, processOptions, pluginOptions */)

Or use it as aPostCSS plugin:

constpostcss=require('postcss')constpostcssNormalize=require('postcss-normalize')postcss([postcssNormalize(/* pluginOptions */)]).process(YOUR_CSS/*, processOptions */)

PostCSS Normalize runs in all Node environments, with special instructionsfor:

NodePostCSS CLIWebpackCreate React AppGulpGrunt

PostCSS Import Usage

PostCSS Normalize includes apostcssImport function to configurePostCSS Import and allow you to continue using the@import syntax.

constpostcss=require('postcss')constpostcssImport=require('postcss-import')constpostcssNormalize=require('postcss-normalize')postcss([postcssImport(postcssNormalize(/* pluginOptions (for PostCSS Normalize) */).postcssImport(/* pluginOptions (for PostCSS Import) */))])// now you can use@import "normalize.css", etc. again

Alternatively, use@import-normalize or@import-sanitize to avoid conflictswith@import transforms.

@import-normalize;
@import-normalize"normalize/opinionated.css";
@import-sanitize;

Options

allowDuplicates

TheallowDuplicates option determines whether multiple, duplicate insertionsof CSS libraries are allowed. By default, duplicate libraries are omitted.

postcssNormalize({allowDuplicates:true})

forceImport

TheforceImport option defines CSS libraries that will be inserted at thebeginning of the CSS file. Unless overriden byallowDuplicates, duplicateCSS libraries would still be omitted.

postcssNormalize({forceImport:true})

Specific CSS libraries may be defined.

postcssNormalize({forceImport:'sanitize.css'})

browsers

Thebrowsers option defines an override of the project’sbrowserslist forPostCSS Normalize. This option should be avoided in leui of a browserslistfile.

postcssNormalize({browsers:'last 2 versions'})

CSS Libraries

PostCSS Normalize can includenormalize.css orsanitize.css andconfigure either with the following combinations:

@import"normalize";/* also, @import "normalize.css" */@import"normalize/opinionated";/* also, @import "normalize.css/opinionated.css", @import "normalize.css/*" */@import"sanitize";/* also, @import "sanitize.css" */@import"sanitize/assets";/* also, @import "sanitize.css/assets.css" */@import"sanitize/forms";/* also, @import "sanitize.css/forms.css" */@import"sanitize/reduce-motion";/* also, @import "sanitize.css/reduce-motion.css" */@import"sanitize/system-ui";/* also, @import "sanitize.css/system-ui.css" */@import"sanitize/typography";/* also, @import "sanitize.css/typography.css" */@import"sanitize/ui-monospace";/* also, @import "sanitize.css/ui-monospace.css" */@import"sanitize/*";/* also, @import "sanitize.css/*" (sanitize + all additions) */

About

Use the parts of normalize.css (or sanitize.css) you need from your browserslist

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp