I have a button with a 2px border and transparent background. And I want to make the background-color become semi-transparent when hover, the hex color code is store in a var() with the name --hexcode. The problem I facing is how to add alpha value after the var() value
:root {
--hexcode: #fff;
}
.stroke-btn {
background-color: transparent;
border: 2px solid #FFF;
color: #FFF;
}
.stroke-btn:hover {
background-color: var(--hexcode) + '88';
}
<button type="button" class="stroke-btn">Click Me<button>
rgba(256,256,256,.88)is#ffffffe0(which you can establish via the browser's color inspector). However, there doesn't seem to be a way to tack this onto the end of your custom property. In any case, you'd have to change the custom property to#fffffffor it to work, or you'd have to tack onfffe0to the end. But I can't figure out any way to tack that on to the end ofvar(--hexcode). I've tried all sorts of combinations, such asvar(--hexcode)fffe0etc., but none of them worked. Interested to know if there is a way.