I want to convert HEX color in RGB, but searching on the web I understood that I can do it with SASS but only with RGBa.
So consider this code:
@mixin hex-rgba($hexcolor, $opacity) {
background-color: rgba($hexcolor, $opacity);
}
div {
@include hex-rgba(#333333, .3);
}
It returns:
div {
background-color: rgba(51, 51, 51, 0.3);
}
But if i set alpha to 1 (or 100%) it returns the hex value:
div {
@include hex-rgba(#333333, 1);
}
div {
background-color: #333333;
}
How can I obtain the rgba value even if alpha is 100%?
In a way like
div {
background-color: rgba(51, 51, 51, 1);
}
SOLVED
@function rgb($hexcolor){
$red:red($hexcolor);
$green:green($hexcolor);
$blue:blue($hexcolor);
$alpha:alpha($hexcolor);
@return unquote("rgb(#{$red},#{$green},#{$blue})");
}
:root {
--color: #{rgb(#ffffff)};
}