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 177 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
Old programmers never die; they just lose some of their functions.