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




PostCSS plugin to transform percentage-based opacity values to more compatible floating-point values.
Using npm:
``bash`
npm install --save-dev postcss postcss-opacity-percentage
Using yarn:
`bash`
yarn add --dev postcss postcss-opacity-percentage
`css`
/ Input /
.foo {
opacity: 45%;
}
`css`
/ Output /
.foo {
opacity: 0.45;
}
`js`
postcss([
require('postcss-opacity-percentage'),
]);
See PostCSS documentation for examples for your environment.
If you are using postcss-preset-env@>=7.3.0, you already have this plugin installed via this package.
The preserve option determines whether the original percentage value is preserved. By default, it is not preserved.
`js`
// Keep the original notation
postcss([
require('postcss-opacity-percentage')({preserve: true}),
]);
`css`
/ Input /
.foo {
opacity: 45%;
}
`css``
/ Output /
.foo {
opacity: 0.45;
opacity: 45%;
}
MIT © Marc Görtz