<div class="switch">
    <input type="checkbox">
    <label><i></i></label>
</div> ​
@import "compass/css3";

*,
*:after,
*:before {
    box-sizing: border-box;
}

.switch input {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 100;
    opacity: 0;
    cursor: pointer;
}

.switch {
    width: 180px;
    height: 50px;
    margin: 60px auto;
    position: relative;
}

.switch label {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    background: #a5a39d;
    border-radius: 40px;
    box-shadow:
        inset 0 3px 8px 1px rgba(0,0,0,0.2),
        0 1px 0 rgba(255,255,255,0.5);
}

.switch label:after {
    content: "";
    position: absolute;
    z-index: -1;
    top: -8px; right: -8px; bottom: -8px; left: -8px;
    border-radius: inherit;
    background: #ccc;
    background: -webkit-linear-gradient(#f2f2f2, #ababab);
    box-shadow: 0 0 10px rgba(0,0,0,0.3),
        0 1px 1px rgba(0,0,0,0.25);
}

.switch label:before {
    content: "";
    position: absolute;
    z-index: -1;
    top: -18px; right: -18px; bottom: -18px; left: -18px;
    border-radius: inherit;
    background: #eee; 
    background: linear-gradient(#e5e7e6, #eee);
    box-shadow: 0 1px 0 rgba(255,255,255,0.5);
    -webkit-filter: blur(1px);
    filter: blur(1px);
}

.switch label i {
    display: block;
    height: 100%;
    width: 60%;
    position: absolute;
    right: 40%;
    top: 0;
    z-index: 2;
    border-radius: inherit;
    background: #b2ac9e;
    background: linear-gradient(#f7f2f6, #b2ac9e);
    box-shadow:
        inset 0 1px 0 white,
        0 0 8px rgba(0,0,0,0.3),
        0 5px 5px rgba(0,0,0,0.2);
}

.switch label i:after {
    content: "";
    position: absolute;
    left: 15%;
    top: 25%;
    width: 70%;
    height: 50%;
    background: #d2cbc3;
    background: linear-gradient(#cbc7bc, #d2cbc3);
    border-radius: inherit;
}

.switch label i:before {
    content: "off";
    position: absolute;
    top: 52%;
    right: -50%;
    margin-top: -12px;
    color: #666;
    color: rgba(0,0,0,0.4);
    font-style: normal;
    font-weight: bold;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 24px;
    text-transform: uppercase;
    text-shadow: 0 1px 0 #bcb8ae, 0 -1px 0 #97958e;
}

.switch input:checked ~ label { 
    background: #9abb82;
}
 
.switch input:checked ~ label i {
    left: auto;
    right: -1%;
}
 
.switch input:checked ~ label i:before {
    content: "on";
    right: 115%;
    color: #82a06a;
    text-shadow: 0 1px 0 #afcb9b, 0 -1px 0 #6b8659;
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js