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

              
                <input type="checkbox" id="lights">
<div class="light-switch">
  <label for="lights">
    <div class="switch"></div>
  </label>
</div>


<!-- Not required for switch. Just for fun. -->
<div class="wall"></div>
              
            
!

CSS

              
                @import "compass/css3";

//Rebound of https://dribbble.com/shots/1753867-light-switch?list=searches&tag=switch&offset=7

// This is where the fun begins.
.light-switch{
  display:block;
  margin: 100px auto;
  border:2px solid #d6d6d5;
  border-left:1px solid #e8e9ea;
  border-top:1px solid #e8e9ea;
  background:#f2f2f3;
   @include border-radius(13px);
  height: 238px;
  width:126px;
  position:relative;
  z-index:1;
/*   @include transform(scale(1)); */
  .switch{
    position:relative;
    border:1px solid #b9bab9;
    margin:13px;
    height:212px;
    width:98px;
    cursor:pointer;
    box-shadow: inset 0px 0px 1px 0px rgba(255,255,255,.25);
    background-color: #f6f7f8; // Old browsers
    z-index:1;
    @include filter-gradient(#f6f7f8, #ffffff, vertical); // IE6-9
    @include background-image(linear-gradient(top, #f6f7f8 0%,#f6f7f8 50%,#ffffff 50%,#ffffff 100%));
    &:after{
      position:absolute;
      bottom:0;
      content:'';
      width:100%;
      height:8px;
      background:rgba(0,0,0,.10);
    }
  }
  input:checked + &{
    background:#b5b5b6;
    border-color:#888;
    .switch{
      @include background-image(linear-gradient(top, #bfbfbf 0%,#bfbfbf 50%,#b8b9ba 50%,#b8b9ba 100%) !important);
      border-color:#888;      
      &:after{
        top:0;
        background:rgba(0,0,0,.10);
      }
    }
    &:after{
      @include transition(all .15s ease-in-out);
      opacity:0;
    }
  }
  &:after{
    position: absolute;
    z-index: -1;
    content: "";
    @include transform(rotate(6deg) scale(0.935) skew(10deg) translate(0px) );
    right:5px;
    bottom:5px;
    width: 0px;
    height: 0px;
    border-style: solid;
    border-width: 0 0 120px 115px;
    border-color: transparent transparent rgba(0,0,0,.15) transparent;
  }
}

//Demo Stuffs

body{
  background:#fdfdf6
}

.wall{
  position:absolute;
  height:100%;
  width:100%;
  top:0;
  left:0;
  @include transition(background .15s ease-in-out);
  input:checked ~ &{ //shout out to @acordova for this line, makes it work in safari
    @include transition(background .15s ease-in-out);
    background:rgba(0,0,0,.25);
  }
}

input{
  opacity:0;
  position:absolute;
}
              
            
!

JS

              
                
              
            
!
999px

Console