Is it possible to define opacity in CSS by percentage (eg 30%) in CSS? does not seem to be working, right now I can only conduct it by decimal point.
https://css-tricks.com/almanac/properties/o/opacity/
.test{
opacity: 0.3;
}
Intended Goal:
.test{
opacity: 30%;
}
A <number> in the range 0.0 to 1.0 , inclusive, or a <percentage> in the range 0% to 100% , inclusive, representing the opacity of the channel (that is, the value of its alpha channel). Any value outside the interval, though valid, is clamped to the nearest limit in the range.
In addition to RGB, you can use an RGB color value with an alpha channel (RGBA) - which specifies the opacity for a color. An RGBA color value is specified with: rgba(red, green, blue, alpha). The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).
Opacity is usually measured as a percentage in design tools, with zero percent being fully transparent, and one hundred percent being fully opaque.
The opacity of a coating is a measure of light that is incident on the coating divided by the amount of light that is transmitted.
Using a percentage is fully valid css, according to the spec: https://developer.mozilla.org/en-US/docs/Web/CSS/opacity#Values
alpha-value
Anumber
in the range 0.0 to 1.0, inclusive, or apercentage
in the range 0% to 100%, inclusive, representing the opacity of the channel (that is, the value of its alpha channel). Any value outside the interval, though valid, is clamped to the nearest limit in the range.
So, either of these should be okay, according to spec:
.foo {
opacity: .3;
}
.foo {
opacity: 30%;
}
Keep in mind, though, that if you are using Sass, it will not handle the percentage
value, and will compile it to 1%
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With