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

              
                <div class="wrap">

  <section>
    <div class="input-wrap">
      <!-- Step 1 -->
      <!-- a checkbox input and label element -->
      <input id="input-1" type="checkbox">
      <label for="input-1">Select</label>
    </div>
  </section>

  <section>
    <div class="input-wrap">
      <input id="input-2" type="checkbox">
      <label for="input-2">Select</label>
    </div> 
  </section>


  <section>
    <div class="input-wrap">
      <input id="input-3" type="checkbox">
      <label for="input-3">Select</label>
    </div> 
  </section>

  <section>
    <div class="input-wrap">
      <input id="input-4" type="checkbox">
      <label for="input-4">Select</label>
    </div> 
  </section>

  <section>
    <div class="input-wrap">
      <input id="input-5" type="checkbox">
      <label for="input-5">Select</label>
    </div> 
  </section>

  <section>
    <div class="input-wrap">
      <input id="input-6" type="checkbox">
      <label for="input-6">Select</label>
    </div> 
  </section>

  <section>
    <div class="input-wrap">
      <input id="input-7" type="checkbox" checked>
      <label for="input-7">Select</label>
    </div> 
  </section>
  
</div>
              
            
!

CSS

              
                section {
  &:nth-of-type(n) {
    // Step 1
    // a checkbox input and label element
    // see html
  }
  &:nth-of-type(n + 2) {
    // Step 2
    // start the label styling
    // with a white background
    label {
      display: inline-block;
      position: relative;
      height: 44px;
      width: 90px;
      background-color: #fff;
    }
  }
  &:nth-of-type(n+3) {
    // Step 3
    // round the corners,
    // hide the font
    // add mouse pointer on hover
    label {
      cursor: pointer;
      font-size: 0;
      color: transparent;
      border-radius: 22px;
    }
  }
  &:nth-of-type(n+4) {
    // Step 4
    // use an after pseudo element
    // to make the grey circle
    label:after {
      content: '';
      display: block;
      height: 40px;
      width: 40px;
      position: absolute;
      top: 2px;
      right: 48px;
      border-radius: 50%;
      background-color: #e8e8e8;
      box-shadow: 2px 0px 0px rgba(0,0,0,0.15);
    }
  }
  &:nth-of-type(n+5) {
    // Step 5
    // use the sibling selector
    // to style the label when
    // the input is checked
    input:checked + label {
      background: #ffd000;
    }
  }
  &:nth-of-type(n+6) {
    // Step 6
    // on input check also...
    // move the circle and
    // change shadow direction
    input:checked + label:after {
      right: 2px;
      background-color: #fff;
      box-shadow: -2px 0px 0px rgba(0,0,0,0.1);
    }
  }
  &:nth-of-type(n+7) {
    // Step 7
    // hide the input checkbox
    // keep visable for screen reader
    // then finally add transition to 
    // label and pseudo element
    input {
      position: absolute !important;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      bottom: 0;
    }
    label {
      transition: background-color 500ms ease;
      &:after {
        transition: right 500ms ease, 
          background-color 500ms ease, 
          box-shadow 500ms ease;
      }
    }
  }
}











// Presentation styles

.wrap {
  display: flex;
  flex-wrap: wrap;
}

section {
  flex: 1;
  padding: 15px 0;
  text-align: center;
  
}

@for $i from 1 through 8 {
  section:nth-of-type(#{$i}) {
    background-color: darken(#eee, $i * 1.5);
   }
}

.input-wrap {
  position: relative;
  padding: 8px;
  min-width: 140px;
}

label {
  line-height: 44px;
  vertical-align: middle;
}
              
            
!

JS

              
                
              
            
!
999px

Console