I am trying to override the alpha value in HSLA using CSS custom property.
In the code below, I wanted to update the alpha value to 0.1, so the final output should be hsla(0, 0%, 26%, 0.1)
. When I inspect the element, it has what I expected, but the rendered output doesn't have the alpha value applied. Any solution for this?
Thanks!
:root {
--bg-color: hsla(0, 0%, 26%, var(--a, 1));
}
.dark {
color: #efefef;
background-color: var(--bg-color);
}
.light {
--a: 0.1;
color: #888;
background-color: var(--bg-color);
}
<div class="dark">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Provident quia, at aliquid temporibus optio ipsa ullam eaque et fugiat? Aliquid fugit facere officiis nostrum. Consequatur maiores aspernatur ipsum ratione facilis!</div>
<div style="margin-top: 3rem"></div>
<div class="light">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Provident quia, at aliquid temporibus optio ipsa ullam eaque et fugiat? Aliquid fugit facere officiis nostrum. Consequatur maiores aspernatur ipsum ratione facilis!</div>