Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1> CSS VARIABLES ARE AWESOME!!</h1>
<p> So, so awesome, we can use <strong>a single line of code </strong> to change a dozen properties, throughout three different selectors (the base element and two pseudo-classes)
<section>
  <button> Red button</button>
  <button class="orange">Orange button </button>
  <button class="yellow">Yellow button </button>
  <button class="lime">Lime button </button>
  <button class="green">Green button </button>
  <button class="teal">Teal button </button>
  <button class="skyblue">Sky Blue button </button>
  <button class="blue">Blue button </button>
  <button class="purple">Purple button </button>
  <button class="fuchsia">Fuchsia button </button>
</section>
              
            
!

CSS

              
                /*setting the basic button, it will be defined as a red version*/
button{
  /*declares and initializes a variable hue within the "button" elements scope, to later use in HSL color declarations for different button parts and status. Also declares a --color variable, for whenever a change from light text to dark text is needed*/
  --hue:0; 
  --color:#FAFAFA;
 /*-----------*/
  font-family: sans-serif;
  margin:10px;
  color:var(--color);
  font-size: 1.5rem;
  outline: none;
  cursor:pointer;
  font-weight:bold;
  border-radius:0.8em;
  padding: 1em; 
  background-color:hsl(var(--hue), 100%, 50%);
  border:5px solid hsl(var(--hue), 100%, 40%);
  box-shadow: 0 5px 2px 0 hsl(var(--hue), 100%, 20%) ;
  position:relative; overflow:hidden;
}

button:hover{
  transform:translateY(-5px);
  box-shadow: 0 10px 2px 0 hsl(var(--hue), 100%, 20%) ;
  background-color:hsl(var(--hue), 100%,70%);
  overflow:visible;
}

button::before{
/* prevents jumpy behaviour when hovered at the lower part*/
  content:"";
  height:calc(100% + 15px);
  width:100%;
  position:absolute; top:0; left:0;
}

button:active{
  transform:translateY(5px);
  box-shadow: 0 0 0 0;
  background-color:hsl(var(--hue), 100%,45%); 
}

/*now through the magic of CSS Variables, redifining the value for the --hue variable on the modifier classes changes the color declarations for all properties and status (regular element, :hover and :active pseudo-classes) IN A SINGLE LINE OF CODE! :D */

.orange{--hue:20;}

.yellow {--hue:50; --color:#444;}

.lime {--hue:80;  --color:#444}

.green {--hue:120;  --color:#444}

.teal{--hue:170; --color:#444}

.skyblue{--hue:200;}

.blue{--hue:240;}

.purple{--hue:270;}

.fuchsia {--hue:300;}


/* aesthetic thingies */
body{
  background:#FBFBFB; 
  font-family: 'Roboto', sans-serif;
}

h1{
  font-size:2.5rem; color: #F11;
  margin: 1rem 1rem 0 1rem;
}

p{
  font-size:1.2rem;
  margin: 0.3rem 1rem 1rem 1rem;
  max-width: 700px;
}

section{
  display:flex;
  flex-wrap:wrap;
}
              
            
!

JS

              
                /*  Without CSS vars, this is the CSS code that we would need for each one of the colors:

.modifier{
  color:#FFF;
  background-color:hsl(270, 100%, 50%);
  border:5px solid hsl(270 100%, 40%);
  box-shadow: 0 5px 2px 0 hsl(270, 100%, 20%) ;
}

.modifier:hover{
  box-shadow: 0 10px 2px 0 hsl(270, 100%, 20%) ;
  background-color:hsl(270, 100%,60%); 
}

.modifier:active{
  background-color:hsl(270, 100%,45%); 
}

quite a bit, and that's for EACH modifier.
So as I said... CSS Variables ROCKS!
*/
              
            
!
999px

Console