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">
  <div class="light">
    <h3>Toggle Switches (Light)</h3>
    <div class="switch">
      <input id="toggle1" class="toggle" checked="true" type="checkbox">
      <label for="toggle1"></label>
      <span class="switch-label">checked</span>
    </div>
    <div class="switch">
      <input id="toggle2" class="toggle" type="checkbox">
      <label for="toggle2"></label>
      <span class="switch-label">UnChecked Toggle</span>
    </div>
    <div class="switch">
      <input id="toggle6" class="toggle" type="checkbox" disabled="disabled">
      <label for="toggle6"></label>
      <span class="switch-label">Disabled</span>
    </div>
    <br><br>
    <br><br>
    <ul>
      <h3>Checkbox Examples</h3>
      <li>
        <input id="checkbox1" class="checkbox" type="checkbox">
        <label for="checkbox1">Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh</label>
      </li>
      <li>
        <input id="checkbox2" class="checkbox" type="checkbox" checked="true">
        <label for="checkbox2">Label for 2</label>
      </li>
      <li>
        <input id="checkbox3" class="checkbox" type="checkbox">
        <label for="checkbox3">Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh</label>
      </li>
      <li>
        <input id="checkbox4" class="checkbox" type="checkbox" disabled="true">
        <label for="checkbox4">Label for 4 (disabled)</label>
      </li>
    </ul>
    <ul>
      <h3>Radio Buttons</h3>
      <li>
        <input id="radio1" class="radio" type="radio" name="radio">
        <label for="radio1">Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh</label>
      </li>
      <li>
        <input id="radio2" class="radio" type="radio" name="radio" checked="true">
        <label for="radio2">Label for 2</label>
      </li>
      <li>
        <input id="radio3" class="radio" type="radio" name="radio">
        <label for="radio3">Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh</label>
      </li>
      <li>
        <input id="radio4" class="radio" type="radio" name="radio" disabled="true">
        <label for="radio4">Label for 4 (disabled)</label>
      </li>
    </ul>
  </div>
  <div class="dark">
    <div class="switch">
      <input id="toggle3" class="toggle" checked="checked" type="checkbox">
      <label for="toggle3"></label>
    </div>
    <div class="switch">
      <input id="toggle4" class="toggle" type="checkbox">
      <label for="toggle4"></label>
      <span class="switch-label">Label</span>
    </div>
    <div class="switch">
      <input id="toggle5" class="toggle" type="checkbox" disabled="disabled">
      <label for="toggle5"></label>
    </div>
        <ul>
      <li>
        <input id="checkboxa" class="checkbox" type="checkbox">
        <label for="checkboxa">Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh</label>
      </li>
      <li>
        <input id="checkboxb" class="checkbox" type="checkbox" checked="true">
        <label for="checkboxb">Label for 2</label>
      </li>
      <li>
        <input id="checkboxc" class="checkbox" type="checkbox" disabled="true">
        <label for="checkboxc">Label for 4 (disabled)</label>
      </li>
    </ul>
    <ul>
      <li>
        <input id="radioa" class="radio" type="radio" name="radio">
        <label for="radioa">Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh Label for checkbox 1 here in the flesh</label>
      </li>
      <li>
        <input id="radiob" class="radio" type="radio" name="radio" checked="true">
        <label for="radiob">Label for 2</label>
      </li>
      <li>
        <input id="radioc" class="radio" type="radio" name="radio" disabled="true">
        <label for="radioc">Label for 4 (disabled)</label>
      </li>
    </ul>
  </div>
</div>
              
            
!

CSS

              
                $inputSize: 1.8rem;
$inputSize--large: 3.4rem;

.container.mobile { // FAILED ATTEMPT TO REDEFINE VARIABLE -- LEAVING HERE AS MOTIVATION
  $inputSize: $inputSize--large }

$color-input--True: rgba(74,188,144,1);
$checkmark--white: url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMjQgMjQiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDI0IDI0IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHBhdGggZmlsbD0iI0ZGRkZGRiIgZD0iTTIwLjYsNS43Yy0wLjUtMC41LTEuMy0wLjUtMS44LDBMOSwxNS41bC0yLjQtMy4yYy0wLjQtMC42LTEuMy0wLjctMS44LTAuMmgwYy0wLjYsMC40LTAuNywxLjMtMC4yLDEuOAoJbDMuMyw0LjNjMC4xLDAuMiwwLjMsMC4zLDAuNSwwLjRjMCwwLDAsMCwwLDBjMC4xLDAsMC4xLDAsMC4yLDAuMWMwLDAsMCwwLDAuMSwwYzAsMCwwLjEsMCwwLjEsMGMwLDAsMC4xLDAsMC4xLDBjMCwwLDAuMSwwLDAuMSwwCgljMC4xLDAsMC4xLDAsMC4yLDBjMCwwLDAsMCwwLjEsMGMwLjEsMCwwLjEsMCwwLjItMC4xYzAsMCwwLDAsMCwwYzAuMS0wLjEsMC4zLTAuMSwwLjQtMC4yTDIwLjYsNy41QzIxLjEsNywyMS4xLDYuMiwyMC42LDUuN3oiLz4KPC9zdmc+);
$checkbox-true: url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9u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jUsMTcuNSwyMiwxMiwyMnoiLz4KPC9nPgo8Y2lyY2xlIGZpbGw9IiM0QUJCOEYiIGN4PSIxMiIgY3k9IjEyIiByPSI4Ii8+Cjwvc3ZnPg==);
$radio-false: url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMjQgMjQiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDI0IDI0IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPGNpcmNsZSBvcGFjaXR5PSIwLjQ4IiBmaWxsPSIjQkJCREJGIiBjeD0iMTIiIGN5PSIxMiIgcj0iMTAiLz4KPC9zdmc+);
$standardDuration: 0.5s;
@mixin truncateText() {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@mixin standardTransition($standardDuration) {
      -webkit-transition: all $standardDuration cubic-bezier(0.915, 0.010, 0.075, 0.995);
         -moz-transition: all $standardDuration cubic-bezier(0.915, 0.010, 0.075, 0.995);
           -o-transition: all $standardDuration cubic-bezier(0.915, 0.010, 0.075, 0.995);
              transition: all $standardDuration cubic-bezier(0.915, 0.010, 0.075, 0.995);
}

/////////////////////////////////////////////
//////////////////////////////
///////////////
// TOGGLE SWITCHES

.switch { 
  height: 4.4rem;
  overflow: hidden;
  width: 7rem;
  position: relative;
  display: inline-block;
  margin: 0;
  padding: 0;
  .switch-label {
    width: 100%;
    font-size: 0.5rem;
    text-transform: uppercase;
    text-align: center;
    @include truncateText;
    color: #999;
    position: absolute; bottom: 0; left:0; right:0;
  }
}

input.toggle {
  visibility: hidden;
  & + label {
    width: 4rem;
    border-radius: 4rem;
    visibility: visible;
    &:hover { cursor: pointer }
  }
  &:disabled + label:before { // bg element
    background-color: rgba(0,0,0,0.1);
    &.dark, .dark & { background-color: rgba(255,255,255,0.075) } }
  &:disabled + label:after { // circle
    background-color: #F5F5F5;
    box-shadow: 0 0.1rem 0.1rem 0rem rgba(0, 0, 0, 0.2);
    &.dark, .dark & { background-color: rgb(70,70,70) } }
}

input.toggle + label:before,
input.toggle + label:after {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  content: "";
}

input.toggle + label:before {
  right: 1rem;
  left: 0.5rem;
  top: 0.8rem;
  bottom: 1.8rem;
  border-radius: 5rem;
  transition: background 0.3s;
  background-color: rgba(0,0,0,0.2);
  &.dark , .dark & { background-color: rgba(255,255,255,0.2) }
}

input.toggle + label:after {
  width: 3rem;
  height: 3rem;
  top: 0.2rem;
  left: 0.3rem;
  background-color: #fff;
  border-radius: 100%;
  box-shadow:  0 0.1rem 0.25rem 0rem rgba(0, 0, 0, 0.3);
  @include standardTransition(0.3s);
  &.dark , .dark & { background-color: rgba(180,180,180,1) }
}

input.toggle:checked + label:before {
  background-color: $color-input--True;
  opacity: 0.5
}

input.toggle:checked + label:after {
  background-color: $color-input--True;
  margin-left: 3rem;
  box-shadow: none
}

/////////////////////////////////////////////
//////////////////////////////
///////////////
// CHECKBOXES AND RADIO BUTTONS

input.checkbox,
input.radio { display: none }

input.checkbox + label,
input.radio + label {
  display:inline-block;
  line-height: 1.7;
  position: relative;
  padding: calc(#{$inputSize} - #{$inputSize} * 0.54) 0 0.5rem calc(#{$inputSize} + 1rem);
  min-height: $inputSize;
  &:hover { cursor: pointer }
}

input.checkbox + label:before,
input.radio + label:before{
  content:"";
  height: $inputSize;
  width: $inputSize;
  position: absolute;
  left: 0.2rem;
  top: 0.7rem;
  background-repeat: no-repeat;
}

input.radio[disabled] + label:before,
input.checkbox[disabled] + label:before { opacity: 0.5 }

input.radio[disabled] + label,
input.checkbox[disabled] + label { color: rgba(0,0,0,0.3) }

// CHECKBOX SPECIFIC
input.checkbox:checked + label:before { background: $checkbox-true }
input.checkbox + label:before { background-image: $checkbox-false }

// RADIO SPECIFIC
input.radio:checked + label:before { background: $radio-true }
input.radio + label:before { background-image: $radio-false }










// NONSENSE -- JUST COLLAPSE HTML TO HIDE THIS CODE -- as it is not part of the custom CSS -- HOWEVER -- .dark class defined witin is required either on the input or on some parent DOM element to get the dark styling, this class name can be altered to suite your needs.
html { font-size: 65.5%; margin: 0; padding: 0; font-family: helvetica, arial; color: #666;
  ul { list-style: none; padding: 0; display: inline-block; width: 30rem; margin-right: 5rem; }
  h3 { text-transform: uppercase; color: #888; }
  p { color: #666 } 
  .container { position: absolute; top:0;bottom:0;right:0;left:0;overflow: hidden; display: flex; flex-direction: column; }
.light, .dark { padding: 2rem; overflow: hidden }
.dark { height: 10rem; position: absolute; bottom: 0; width: 100%; background-color: #282828}
.light { overflow-x: hidden; overflow-y: auto; position: absolute; bottom: 14rem; top:0; left: 0; right:0;}
}
              
            
!

JS

              
                $(document).ready(function() {
    if ($(window).width()< 600) {
      console.log("hey, it worked on load")
     $('.container').addClass('mobile');
    }
    else {$('.container').removeClass('mobile');}
 });

$(window).resize(function() {
    if ($(window).width() < 600) {
      console.log("hey, it worked on resize")
     $('.container').addClass('mobile');
    }
    else {$('.container').removeClass('mobile');}
 });
              
            
!
999px

Console