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

              
                <div class="toggle">  
  <!-- Checkbox toggle -->
  <input type="checkbox" value="selected" id="beethoven-joke" class="toggle-input">
  <label for="beethoven-joke" class="toggle-label">What was Beethoven's favorite fruit?</label> 
  
  <!-- Content to toggle -->
  <div role="toggle" class="toggle-content">
    BA-NA-NA-NA!
 </div>
</div>

<div class="toggle">  
  <!-- Checkbox toggle -->
  <input type="checkbox" value="selected" id="army-joke" class="toggle-input">
  <label for="army-joke" class="toggle-label">Where did the general put his armies?</label> 
  
  <!-- Content to toggle -->
  <div class="toggle-content">
    Up his sleevies!
 </div>
</div>

<div class="toggle">  
  <!-- Checkbox toggle -->
  <input type="checkbox" value="selected" id="pepper-joke" class="toggle-input">
  <label for="pepper-joke" class="toggle-label">What do you call a nosy pepper?</label> 
  
  <!-- Content to toggle -->
  <div role="toggle" id="beethoven-joke" class="toggle-content">
    Jalapeño business!
 </div>
</div>
              
            
!

CSS

              
                //Forked from https://codepen.io/lottejackson/pen/ogeONj

//Setting up the pen
html,
body {
  background-color: #363642;
  color: #2D2D36;
  font-family: Helvetica, sans-serif;
  padding: 4rem;
}

.toggle {
  margin: 0 auto;
  max-width: 400px;
}

//Style toggle
.toggle-label {
  font-size: 16px;
  background: #fff;
  padding: 1em;
  cursor: pointer;
  display: block;
  margin: 0 auto 1em;
  box-shadow: 0 1px 2px 0 rgba(153, 153, 153, 0.35);
  border-radius: 4px;
  
  &:after {
    color: #ED3E44;
    content: "+";
    float: right;
    font-weight: bold;
  }
}

//Style content
.toggle-content {
  color: #B0B3C2;
  font-family: monospace;
  font-size: 16px;
  margin-bottom: 1.5em;
  padding: 1em;
}

.toggle-input {
  display: none; //Hide input element
  
  &:not(checked) ~ .toggle-content {
    display: none; //Hide content
  }
}

//Display content when checkbox is "checked"
.toggle-input:checked {
  ~ .toggle-content {
    display: block;
  }
  
  ~ .toggle-label {
    &:after {
      content: "-"; //Change label's '+' to '-' when checked
    }
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console