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.

            
              <div class="container">
  <h1 data-value="Switch">switch</h1>
  
  <div class="switch">
    <input type="checkbox" />
    <label><i></i></label>
    <span class="fontawesome-remove"></span>
    <span class="fontawesome-ok"></span>
  </div>
    
  <p>inspired by <a href="http://dribbble.com/shots/1194133-Switch?list=playoffs">nos</a></p>
</div>
            
          
!
            
              @import url(http://weloveiconfonts.com/api/?family=fontawesome);

// font wesome
[class*="fontawesome-"]:before {
  color: #fff;
  font-family: 'FontAwesome', sans-serif;
  font-size: 2em;
}

// base
html {
  font-family: sans-serif; 
}

body {
  background: #cedfe9;
  color: #878787;
}

.container {
  height: 150px;
  margin: 150px auto 0;
  text-align: center;
  width: 500px; 
}

h1 {
  letter-spacing: 1px;
  margin-bottom: 25px;
}

a {
  color: #30a3f3;
  position: relative;
  text-decoration: none;
  
  &::after {
    background: #30a3f3;
    bottom: -1px;
    content: '';
    height: 1px;
    right: -1px;
    opacity: 0;
    position: absolute;
    width: 106%;
    
    -webkit-transform: translateY(-12px);
    -moz-transform: translateY(-12px);
    transform: translateY(-12px);
    
    -webkit-transition: opacity 0.15s, -webkit-transform 0.2s;
    -moz-transition: width 0.15s, -moz-transform 0.2s;
    transition: width 0.15s, transform 0.2s;
  }
  
  &:hover {
   &::after {
      opacity: 1;
      
      -webkit-transform: translateY(0);
      -moz-transform: translateY(0);
      transform: translateY(0);
    }
  }
}

// checkbox
.switch {
  border-radius: 10px;
  height: 51px;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
  width: 145px;
}

input[type=checkbox] {
  bottom: 0;
  cursor: pointer;
  height: 100%;
  left: 0;
  opacity: 0;
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  z-index: 100;
}

label {
  display: block;
  height: 100%;
  width: 100%;
}

// button style
i {
  left: 0;
  position: absolute;
  top: 15px;
  z-index: 3;
  
  -webkit-transition: left 0.2s ease-out;
  
  &::before,
  &::after {
    content: '';
    display: block;
    position: absolute;
  }
  
  &::before {
    background: -moz-linear-gradient(top, #ffffff 0%, #f0f0f0 100%);
    background: -webkit-linear-gradient(top, #ffffff 0%,#f0f0f0 100%);
    background: -ms-linear-gradient(top, #ffffff 0%,#f0f0f0 100%);
    border-radius: 10px;
    height: 45px;
    left: 5px;
    top: -12px;
    width: 60px;
  }
  
  &::after {
    background: #000;
    background: -moz-linear-gradient(top, #e9e9e9 0%, #ffffff 100%);
    background: -webkit-linear-gradient(top, #e9e9e9 0%,#ffffff 100%);
    background: -ms-linear-gradient(top, #e9e9e9 0%,#ffffff 100%);
    border-radius: 50%;
    box-shadow: inset 0 0 3px rgba(0,0,0,0.05);
    height: 28px;
    left: 20px;
    top: -3px;
    width: 28px;
  }
}

// icons
[class*="fontawesome-"] {
  border-radius: 10px;
  box-sizing: border-box;
  display: block;
  height: 51px;
  padding: 9px 20px;
  position: absolute;
  top: 0px;
  width: 145px;
  z-index: 2;
}

.fontawesome-remove {
  background: -moz-linear-gradient(top, #878787 0%, #686868 100%);
  background: -webkit-linear-gradient(top, #878787 0%,#686868 100%);
  background: -ms-linear-gradient(top, #878787 0%,#686868 100%);
  box-shadow: inset 0 0 1px #000;
  left: 0px;
  text-align: right;
}

.fontawesome-ok {
  background: -moz-linear-gradient(top, #30a3f3 0%, #2372d9 100%);
  background: -webkit-linear-gradient(top, #30a3f3 0%,#2372d9 100%);
  background: -ms-linear-gradient(top, #30a3f3 0%,#2372d9 100%);
  box-shadow: inset 0 0 1px #1d69cb;
  left: -145px;
  text-align: left;
}


// checked state
input[type=checkbox]:checked ~ label i {
  left: 52%;
}

input[type=checkbox]:checked ~ .fontawesome-remove {
  left: 145px;
}

input[type=checkbox]:checked ~ .fontawesome-ok {
  left: 0;
}
            
          
!
999px
Loading ..................

Console