custom css code example
Example 1: css custom properties
/* create */
:root {
--variable-name: variable-property;
}
/* use */
selector {
property: var(--variable-name);
}
Example 2: css how to style a
/*a normal, unvisited link*/
a:link{
color: green;
}
/*a link the user has visited*/
a:visited{
color: purple;
}
/*a link when the user mouses over it*/
a:hover{
color: yellow;
}
/*a link the moment it is clicked*/
a:active{
color: brown;
}
Example 3: custom properties css
// get variable from inline style
element.style.getPropertyValue("--my-var");
// get variable from wherever
getComputedStyle(element).getPropertyValue("--my-var");
// set variable on inline style
element.style.setProperty("--my-var", jsVar + 4);