postcss-opacity-percentage

PostCSS plugin to transform percentage-based opacity values to more compatible floating-point values.

MIT 10 个版本
安装
npm install postcss-opacity-percentage
yarn add postcss-opacity-percentage
pnpm add postcss-opacity-percentage
bun add postcss-opacity-percentage
README

PostCSS Opacity Percentage

Test Coverage Status Install size XO code style MIT license

PostCSS plugin to transform percentage-based opacity values to more compatible floating-point values.

Install

Using npm:

npm install --save-dev postcss postcss-opacity-percentage

Using yarn:

yarn add --dev postcss postcss-opacity-percentage

Example

/* Input */
.foo {
  opacity: 45%;
}
/* Output */
.foo {
  opacity: 0.45;
}

Usage

postcss([
  require('postcss-opacity-percentage'),
]);

See PostCSS documentation for examples for your environment.

postcss-preset-env

If you are using postcss-preset-env@>=7.3.0, you already have this plugin installed via this package.

Options

preserve

The preserve option determines whether the original percentage value is preserved. By default, it is not preserved.

// Keep the original notation
postcss([
  require('postcss-opacity-percentage')({preserve: true}),
]);
/* Input */
.foo {
  opacity: 45%;
}
/* Output */
.foo {
  opacity: 0.45;
  opacity: 45%;
}

License

MIT © Marc Görtz

版本列表
3.0.0 2024-09-03
2.0.0 2023-01-31
1.1.3 2022-12-16
1.1.2 2022-01-31
1.1.1 2022-01-26
1.1.0 2021-12-29
1.0.0 2021-11-08
0.0.3 2021-11-08
0.0.2 2021-11-08
0.0.1 2021-11-08