toggle with background image
by Ayyappan Sakthivadivel
HTML
<div class="wrapper">
<input id="dn" type="checkbox" /><label class="toggle" for="dn"><span class="toggle--handler"></span></label>
</div>
CSS
label > * {
-webkit-transform: translateZ(0) scale(1, 1);
transform: translateZ(0) scale(1, 1);
}
.wrapper > * {
cursor: pointer;
}
.wrapper {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 150px;
height: 75px;
background: #F1F1F1;
box-shadow: inset 0px 0px 5px 0px rgba(0, 0, 0, 0.1);
border-radius: 75px;
}
.wrapper .toggle--handler {
/*background: -webkit-gradient(linear, left top, left bottom, from(#F5515F), to(#CD2942));
background: linear-gradient(to bottom, #F5515F, #CD2942);*/
background-color: #F5515F;
background-image: url("https://cdn4.iconfinder.com/data/icons/apply-pixels-glyphs/40/Checkmark-512.png");
background-repeat: no-repeat;
background-size: contain;
width: 60px;
height: 60px;
display: block;
box-shadow: 0px 5px 40px rgba(245, 81, 95, 0.8);
border-radius: 60px;
margin: 7.5px;
position: relative;
z-index: 2;
-webkit-transition: all 200ms cubic-bezier(0.445, 0.05, 0.55, 0.95);
transition: all 200ms cubic-bezier(0.445, 0.05, 0.55, 0.95);
}
.wrapper .toggle--handler:after {
content: "";
position: absolute;
border-radius: 60px;
/*background: -webkit-gradient(linear, left top, left bottom, from(#468EFF), to(#2B68FF));
background: linear-gradient(to bottom, #468EFF, #2B68FF);*/
background-image: url("https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-close-512.png");
background-repeat: no-repeat;
background-size: contain;
width: 100%;
height: 100%;
opacity: 0;
-webkit-transition: all 200ms;
transition: all 200ms;
}
.wrapper .toggle--handler:before {
content: "";
position: absolute;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 24px;
height: 24px;
border-radius: 60px;
background-image: url('data:image/svg+xml;utf8,<svg width="24" height="24" viewBox="0 0 24 24"...