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

              
                
    <nav class="navbar">Title</nav>
    <div class="container">
        <div>
            <input type="button" value="Red" id="toggle-red" />
                      <input type="button" value="Blue" id="toggle-blue" />            <input type="button" value="Green" id="toggle-green" />
            
        </div>

        <h2 class="title">What is Lorem Ipsum?</h2>
        <p class="content">
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
            text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
            book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially
            unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
            and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
        </p>
    </div>
    <footer>
        Copyright 2018
    </footer>

              
            
!

CSS

              
                :root{
  --red-hue: 360;
  --blue-hue: 240;
  --green-hue: 120;
  --main-hue : var(--red-hue);
}

* {
  margin: 0;
}
html{
  height: 100%;
}
body{
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont,
  “Segoe UI”, “Roboto”, “Oxygen”, “Ubuntu”, “Cantarell”,
  “Fira Sans”, “Droid Sans”, “Helvetica Neue”,
  sans-serif;
  display: flex;
  flex-direction: column;
}
nav{
  background: hsl(var(--main-hue) , 50%, 50%);
  padding: 1.3rem;
  color: hsl(var(--main-hue) , 50%, 50%);
}
.container{
  flex: 1;
  background:hsl(var(--main-hue), 50%, 95%);
  padding: 1rem;
}
p.content{
  padding: 0.7rem;
  font-size: 0.7rem;
  color: hsl(var(--main-hue), 50%, 50%);
}
.container h2.title{
  padding: 1rem;
  color: hsl(var(--main-hue), 50%, 20%);
}
footer{
  background: hsl(var(--main-hue), 93%, 88%);
  padding: 1rem;
}
input[type=button] {
  color:hsl(var(--main-hue), 50%, 20%);
  padding: 0.3rem;
  font-size: 1rem;
}
* {
  margin: 0;
}
html{
  height: 100%;
}
body{
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont,
  “Segoe UI”, “Roboto”, “Oxygen”, “Ubuntu”, “Cantarell”,
  “Fira Sans”, “Droid Sans”, “Helvetica Neue”,
  sans-serif;
  display: flex;
  flex-direction: column;
}
nav{
  background: hsl(var(--main-hue), 50%, 50%);
  padding: 1.3rem;
  color: hsl(var(--main-hue), 50%, 10%);
}
.container{
  flex: 1;
  background:hsl(var(--main-hue), 50%, 95%);
  padding: 1rem;
}
p.content{
  padding: 0.7rem;
  font-size: 0.7rem;
  color: hsl(var(--main-hue), 50%, 50%);
}
.container h2.title{
  padding: 1rem;
  color: hsl(var(--main-hue), 50%, 20%);
}
footer{
  background: hsl(var(--main-hue), 93%, 88%);
  padding: 1rem;
}
input[type=button] {
  color:hsl(var(--main-hue), 50%, 20%);
  padding: 0.3rem;
  font-size: 1rem;
}
              
            
!

JS

              
                document.body.onload = ()=>{
  
  const redBtn = document.querySelector('#toggle-red');
  const blueBtn = document.querySelector('#toggle-blue');
  const greenBtn = document.querySelector('#toggle-green');
  
  redBtn.addEventListener('click',(e)=>{
 
    console.log("red");
    document.documentElement.style.setProperty('--main-hue', 360);
 })
  
blueBtn.addEventListener('click',(e)=>{
    document.documentElement.style.setProperty('--main-hue', 240);
  })
  
  greenBtn.addEventListener('click',(e)=>{
    document.documentElement.style.setProperty('--main-hue', 120);
  })  
}
              
            
!
999px

Console