TwistedOrange / Bloc-docs

0 stars 0 forks source link

CSS: Variables #5

Closed TwistedOrange closed 7 years ago

TwistedOrange commented 7 years ago

Variables in CSS

:root {
  --base: #000;
}

div {
  background-color: var(--base)
} 

You can also set variables in-line: <html style='--base: #fff'>. If you put the variables in the :rootyou can change them like so: document.documentElement.style.setProperty('--base', ‘20px') and change them throughout the DOM.

TwistedOrange commented 7 years ago

citation: Everything I learned from #Javascript30 - Amber Wilkie