cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <form class="toggle">
  <label>This is a custom CSS checkbox.</label>
  <div class="switch">
    <input type="checkbox">
    <span class="thumb"></span>
    <span class="x"></span>
    <span class="o"></span>
  </div>
</form>
            
          
!
            
              /* Import the Google Font 'Ubuntu' */
@import url(https://fonts.googleapis.com/css?family=Ubuntu);

body {
  background-color: #333333;
  color: #CCCCCC;
  font-family: Ubuntu, sans-serif;
  font-size: 24px;
  letter-spacing: 2px;
  padding: 50px;
  text-align: center;
}

.toggle {}

.toggle > label {
  display: block;
  margin-bottom: 15px;
}

/* Wrapper for the control */
.switch {
  display: inline-block;
  position: relative;
  width: 200px;
  height: 100px;
  
  background: rgba(0, 0, 0, .1);
  border: 1px solid rgba(0, 0, 0, .2);
  box-shadow: 1px 1px 2px rgba(0, 0, 0, .2);
}

/* Input toggle styles */
input[type="checkbox"] {
  display: block;
  width: 100%;
  height: 100%;
  text-align: center;
  
  margin: 0;
  padding: 0;
  opacity: 0;
  
  outline: none;
}

/* Checkbox state styles */
input[type="checkbox"] ~ .x,
input[type="checkbox"] ~ .o {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  z-index: -2;
  transition: opacity 500ms;
}



input[type="checkbox"] ~ .x {
  background-image: linear-gradient(45deg, transparent, transparent 45%, red 45%, red 55%, transparent 55%, transparent),
                    linear-gradient(135deg, transparent, transparent 45%, red 45%, red 55%, transparent 55%, transparent);
  background-size: 50% 65%;
  background-position: right;
  
}

input[type="checkbox"] ~ .o {
  background-image: radial-gradient(transparent, transparent 45%, green 48%, green 58%, transparent 60%, transparent);
  background-size: 50% 100%;
  background-position: left;
  opacity: 0;
}

input[type="checkbox"] ~ .thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  z-index: -1;
  background-color: red;
  transition: left 500ms, background-color 500ms;
}

input[type="checkbox"]:checked ~ .x {
  opacity: 0;
}

input[type="checkbox"]:checked ~ .o {
  opacity: 1;
}

input[type="checkbox"]:checked ~ .thumb {
  background-color: green;
  left: 50%;
}


            
          
!
999px
Loading ..................

Console