Pure CSS Shiny animated checkboxes
Instead of creating a directive or jquery plugin, creating a silky looking checkbox can simply be done using :checked + whatever {}
CSS
.switch{
display: inline-block;
line-height: 1;
}
.switch input {
display: none;
}
.switch i {
position: relative;
display: inline-block;
cursor: pointer;
padding: .15em 1.5em .15em .15em;
transition: all ease 0.2s;
-webkit-transition: all ease 0.2s;
border-radius: 1em;
background-color: gray;
overflow: hidden;
}
.switch i::before {
display: block;
content: '';
width: 1em;
height: 1em;
border-radius: 1em;
background: white;
}
.switch i::after {
position: absolute;
display: block;
text-transform: uppercase;
font-size: .5em;
font-style: normal;
top: 0;
color: #fff;
line-height: 1;
content: 'off';
left: 0;
padding-left: 2em;
width: 100%;
box-sizing: border-box;
text-align: center;
height: 1em;
bottom: 0;
margin: auto;
}
.switch :checked + i::after {
padding-left: 0;
padding-right: 2em;
content: 'on';
}
.switch :checked + i {
padding-right: .15em;
padding-left: 1.5em;
background-color: green;
}
.switch.switch-red :checked + i {
background-color: red;
}