h1 Google Switch Collection
div class="switch-container"
div class="headcontainer"
p class="name" Lollipop
div class="switchlollipop"
<input type="radio" name="switchlollipop" checked>
<input type="radio" name="switchlollipop" id="switch-on-lollipop">
span class="slider"
span class="togglelollipop"
div class="switch-container"
div class="headcontainer"
p class="name" Kitkat
div class="switchkitkat"
<input type="radio" name="switchkitkat" checked>
<input type="radio" name="switchkitkat" id="switch-on-kitkat">
span class="togglekitkat"
div class="switch-container"
div class="headcontainer"
p class="name" Google Inbox
div class="switchinbox"
<input type="radio" name="switch" class="switch-off" checked>
<input type="radio" name="switch" class="switch-on">
span class="toggleinbox"
img class="toggleimg" src="//ssl.gstatic.com/bt/C3341AA7A1A076756462EE2E5CD71C11/1x/bt_pin_toggle_off_15dp_r3.png"
p class="firma"
a class="write" href="https://plus.google.com/105749628523180076386/posts" data-toggle="tooltip" data-placement="top" data-original-title="Profile" target="_blank" Simone Bernabè -
a href="https://codepen.io/collection/XyrMQr/" data-toggle="tooltip" data-placement="top" data-original-title="Google Collection" target="_blank" Check Out my Collection
View Compiled
body{
font-family: 'Roboto';
background: #f1f1f1;
}
h1{
text-align: center;
color: #222;
}
.switch-container{
width: 400px;
height: 250px;
background: white;
position: relative;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
margin-bottom: 30px;
border-radius: 3px;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
overflow: hidden;
}
/* LOLLIPOP SWITCH */
.switchlollipop{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
width: 67px;
height: 25px;
}
.switchlollipop input {
height: 64px;
left: 0;
opacity: 0;
position: absolute;
top: 0;
width: 160px;
z-index: 2;
cursor: pointer;
}
.slider{
background: #b2b2b2;
height: 25px;
border-radius: 20px;
position: absolute;
-webkit-transition: left .2s ease;
-moz-transition: left .2s ease;
-ms-transition: left .2s ease;
-o-transition: left .2s ease;
transition: left .2s ease;
width: 67px;
z-index: 1;
}
.switchlollipop input:checked~.toggle {
left: 0px;
}
.switchlollipop input~:checked~.togglelollipop {
left: 35px;
}
.switchlollipop input:checked {
z-index: 0;
}
.togglelollipop {
background: #ececec;
height: 35px;
border-radius: 50%;
top: -6px;
left: 0;
position: absolute;
-webkit-transition: left .2s ease;
-moz-transition: left .2s ease;
-ms-transition: left .2s ease;
-o-transition: left .2s ease;
transition: left .2s ease;
width: 35px;
z-index: 1;
box-shadow: 0px 2px 4px 0px #666;
}
#switch-on-lollipop:checked + .slider{
background: #b2deda;
}
#switch-on-lollipop:checked ~ .togglelollipop{
background: #009385;
}
/* KITKAT SWITCH */
.switchkitkat {
background: #444;
display: block;
height: 25px;
position: absolute;
width: 100px;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.switchkitkat input {
height: 64px;
left: 0;
opacity: 0;
position: absolute;
top: 0;
width: 160px;
z-index: 2;
cursor: pointer;
}
.switchkitkat input:checked~.togglekitkat {
left: 0px;
}
.switchkitkat input~:checked~.togglekitkat {
left: 51px;
}
.switchkitkat input:checked {
z-index: 0;
}
.togglekitkat {
background: #999;
height: 25px;
top: 0px;
left: 0;
position: absolute;
-webkit-transition: left .2s ease;
-moz-transition: left .2s ease;
-ms-transition: left .2s ease;
-o-transition: left .2s ease;
transition: left .2s ease;
width: 50px;
z-index: 1;
}
#switch-on-kitkat:checked + .togglekitkat::after{
content:"OFF";
}
.togglekitkat::after{
content: "ON";
left: 0;
right: 0;
position: absolute;
margin-left: auto;
margin-right: auto;
text-align: center;
color: #222;
font-family: 'Roboto';
top: 0;
bottom: 0;
line-height: 25px;
}
/* Google Inbox Switch */
.switchinbox {
background: #3262ba;
border-radius: 32px;
display: block;
height: 20px;
position: absolute;
width: 40px;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.switchinbox input {
height: 64px;
left: 0;
opacity: 0;
position: absolute;
top: 0;
width: 160px;
z-index: 2;
cursor: pointer;
}
.switchinbox input:checked~.toggleinbox {
left: -10px;
}
.switchinbox input~:checked~.toggleinbox {
left: 26px;
}
.switchinbox input:checked {
z-index: 0;
}
.toggleinbox {
background: #4285f4;
border-radius: 50%;
height: 28px;
top: -4px;
left: 0;
position: absolute;
-webkit-transition: left .2s ease;
-moz-transition: left .2s ease;
-ms-transition: left .2s ease;
-o-transition: left .2s ease;
transition: left .2s ease;
width: 28px;
z-index: 1;
box-shadow: 0px 2px 4px 0px #222;
}
.toggleimg{
line-height: 28px;
top: 0;
bottom: 0;
margin: auto;
left: 0;
right: 0;
position: absolute;
}
.headcontainer{
height: 30px;
width: 100%;
background: #262626;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
.name{
color: white;
text-align: center;
line-height: 30px;
margin: 0;
padding: 0;
}
.firma{
text-align: center;
padding-top: 20px;
font-family: 'Roboto';
color: #555;
font-size: 14px;
font-weight: 300;
padding-bottom: 20px;
}
a:visited, a:link{
text-decoration: none;
color: #555;
}
.write{
color: #db4437 !important;
font-weight: 500;
}
$('.switchinbox').click(function() {
if ($(".switch-on").is(':checked')) {
$(".switchinbox").css("background", "#DDD");
$(".toggleinbox").css("background", "white");
$(".toggleimg").attr("src", "//ssl.gstatic.com/bt/C3341AA7A1A076756462EE2E5CD71C11/1x/bt_pin_toggle_on_15dp_r3.png");
} else {
$(".switchinbox").css("background", "#3262ba");
$(".toggleinbox").css("background", "#4285f4");
$(".toggleimg").attr("src", "//ssl.gstatic.com/bt/C3341AA7A1A076756462EE2E5CD71C11/1x/bt_pin_toggle_off_15dp_r3.png");
}
});
This Pen doesn't use any external CSS resources.