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>
2
Answers
Use the following:
If that doesn’t work, then use this to define your
var
:You can create a variable in hex format with the alpha included.