Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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="container">
  <h4>Toggle Switch</h4>
  <p>Checkbox</p>
  <label class="switch">
    <input type="checkbox" id="change-bg">
    <div class="slider round"></div>
  </label>
  
  <label class="switch">
    <input type="checkbox">
    <div class="slider round"></div>
  </label>
  
  <label class="switch">
    <input type="checkbox">
    <div class="slider round"></div>
  </label>
  
  <p>Radio button</p>
  <label class="switch">
    <input type="radio" name="option">
    <div class="slider round"></div>
  </label>
  
  <label class="switch">
    <input type="radio" name="option">
    <div class="slider round"></div>
  </label>
  
  <label class="switch">
    <input type="radio" name="option">
    <div class="slider round"></div>
  </label>
  
  <p>Change Background</p>
  
  <label class="switch">
    <input type="radio" id="bg-default" name="background" checked>
    <div class="slider round bg-default"></div>
  </label>
  
  <label class="switch">
    <input type="radio" id="bg-purple" name="background">
    <div class="slider round bg-purple"></div>
  </label>
  
  <label class="switch">
    <input type="radio" id="bg-orange" name="background">
    <div class="slider round bg-orange"></div>
  </label>
  
</div>


              
            
!

CSS

              
                body
  background-color: #1C1C1C
  
.container
  width: 80%
  background-color: #eee
  padding: 10px 20px 20px
  margin: 50px auto 0
  text-align: center
  
  h4
    font-size: 1.5rem
    border-bottom: 1px solid rgba(0,0,0,0.1)
    padding-bottom: 40px
    
  h4,
  p
    font-weight: bold
    text-transform: uppercase
    color: #434343
    font-family: Arial, Calibri, Helvetica
    
.switch
  position: relative
  height: 30px
  width: 60px
  display: inline-block
  
  input
    display: none
  
  input:checked + .slider
    background-color: #42e2f4
    
  input:checked + .slider:before
    -webkit-transform: translate(26px, -50%)
    -ms-transform: translate(26px, -50%)
    transform: translate(26px, -50%)
    
.slider
  position: absolute
  background-color: pink
  top: 0
  right: 0
  bottom: 0
  left: 0
  cursor: pointer
  -webkit-transition: 0.4s
  transition: 0.4s
  
  &:before
    content: ""
    position: absolute
    width: 20px
    height: 20px
    background-color: white
    top: 50%
    left: 6px
    transform: translateY(-50%)
    -webkit-transition: 0.4s
    transition: 0.4s

.round
  border-radius: 20px
  
  &:before
    border-radius: 50%

// BG Colour Scheme
.bg-default,
input:checked + .slider.bg-default
  background-color: #1C1C1C

.bg-purple,
input:checked + .slider.bg-purple 
  background-color: purple
  
.bg-orange,
input:checked + .slider.bg-orange 
  background-color: orange

// Fade in BG colours
.bg-default,
input:checked + .slider.bg-default,
.bg-purple,
input:checked + .slider.bg-purple,
.bg-orange,
input:checked + .slider.bg-orange
  -webkit-transition: 0.8s
  transition: 0.8s
              
            
!

JS

              
                $("input[name=background]").on("change", function(){
  var bg = $(this).attr("id");
  $("body").removeClass();
  $("body").addClass( bg );
});


              
            
!
999px

Console