A quick question to which the answer is probably \"NO\", but I\'m new to CSS variables so I\'m not sure.
If I want to define color and later be able to add alpha cha
You are almost good, you simply need to pay attention to the syntax:
:root {
--c:255,0 ,0;
--o:0.5;
}
html {
background:rgba(var(--c),var(--o));
}
body {
background:rgb(var(--c));
height:100px;
}
.box {
--c:12,12,12;
--o:0.7;
background:rgba(var(--c),var(--o));
color:#fff;
}
some content
You can also define each channel alone:
:root {
--r:255;
--g:0;
--b:0;
--c:var(--r),var(--g) ,var(--b);
--o:0.5;
}
html {
background:rgba(var(--c),var(--o));
}
body {
background:rgb(var(--c));
height:100px;
}
.box {
--c:12,12,12;
--o:0.7;
background:rgba(var(--c),var(--o));
color:#fff;
}
some content