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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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 Pure CSS Toggle Switches
.centered 
  .card
    label(for='switch1')
      input(type='checkbox' id='switch1')
      span.switch
      span.toggle     
  br 
  .card
    label(for='switch2')
      input(type='checkbox' id='switch2' checked)
      span.switch
      span.toggle
              
            
!

CSS

              
                // One variable to rule them all :)

// All dimentions are based on this one variable; Change it's value and see everythinmg else change accordingly.

$width: 100px; // Change Me
$height: $width / 2.5;

input[type='checkbox'] {
  display: none;
  
  &:checked ~ .toggle {
    background: #009688;
    left: ($width - ($height * 1.4 - $height) / 2) - $height;
    transition: .5s;
  }
  
  &:checked ~ .switch {
    background: #6DBEB7;  
    transition: .5s;
  }
}

.switch {
  display: block;
  width: $width;
  height: $height;
  background: #939393;
  border-radius: $height / 2;
  position: absolute;
  top: 0;
  transition: .5s;
}

.toggle {
  height: $height * 1.4;
  width: $height * 1.4;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: ($height * 1.4 - $height) / -2;
  left: ($height * 1.4 - $height) / -2;
  box-shadow: 0 $width / 50 $width / 25 rgba(black, .4);
  transition: .5s;
}

.card {
  display: inline-block;
  margin: (($height * 1.4 - $height) / 2) + 5px;
    margin: (($height * 1.5 - $height) / 2);
  width: $width;
  height: $height;
  text-align: center;
  position: relative;
}

// Second switch coloration

#switch2 {
  &:checked ~ .toggle {
    background: #3F51B5;
  } 
  &:checked ~ .switch {
    background: #9CA5D7;  
  }
}

// Unnecessary styling

body {background: #EEE;}
h1 {
  font: 300 45px Roboto;
  text-align: center;
}
.centered {
  position: absolute;
  top: calc(50% - #{$height * 1.5});
  left: calc(50% - #{$width / 2 + $height * .25});  
}
              
            
!

JS

              
                
              
            
!
999px

Console