setting up css variables in your stylesheet

Using css variables at the start of your stylesheet can make things down the road much easier to change.

You can also use it for more complex variables like drop shadow settings as shown below. 

HTML

<div class='demo-box main-pink'></div>

CSS

:root {
	/* Main Colours */
	--main-pink: pink; /* e.g: color: var(--main-pink); */
	--main-red: red; /* e.g: color: var(--main-red);  */

	/* Shadows */
	--main-drop-shadow: 0px 10px 20px rgba(0,0,0,0.5); /* box-shadow: var(--main-drop-shadow); */
}
.demo-box {
  height:100px;
  width:100px;
}
.main-pink {
  background: var(--main-pink);
  box-shadow: var(--main-drop-shadow);
}

Other Items in css
Page Views

This page has been viewed 42 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹

Random Quote
Don't look to be the next Facebook, try to solve a real problem instead.
Unknown