Last active
April 26, 2017 06:47
-
-
Save Graniron/b856e7f73d3655ba1c1e750112e3966c to your computer and use it in GitHub Desktop.
Flip toggle(from https://codepen.io/mallendeo/pen/eLIiG)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input class="tgl tgl-flip" id="cb5" type="checkbox" ng-model="vm.pattern.isPublic"> | |
<label class="tgl-btn" data-tg-off="Private" data-tg-on="Public" for="cb5"></label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.tgl { | |
display: none; | |
// add default box-sizing for this scope | |
&, | |
&:after, | |
&:before, | |
& *, | |
& *:after, | |
& *:before, | |
& + .tgl-btn { | |
box-sizing: border-box; | |
&::selection { | |
background: none; | |
} | |
} | |
+ .tgl-btn { | |
outline: 0; | |
display: block; | |
width: 4em; | |
height: 2em; | |
position: relative; | |
cursor: pointer; | |
user-select: none; | |
&:after, | |
&:before { | |
position: relative; | |
display: block; | |
content: ""; | |
width: 50%; | |
height: 100%; | |
} | |
&:after { | |
left: 0; | |
} | |
&:before { | |
display: none; | |
} | |
} | |
&:checked + .tgl-btn:after { | |
left: 50%; | |
} | |
} | |
.tgl-flip { | |
+ .tgl-btn { | |
padding: 2px; | |
transition: all .2s ease; | |
font-family: sans-serif; | |
perspective: 100px; | |
&:after, | |
&:before { | |
display: inline-block; | |
transition: all .4s ease; | |
width: 100%; | |
text-align: center; | |
position: absolute; | |
line-height: 2em; | |
font-weight: bold; | |
color: #fff; | |
position: absolute; | |
top: 0; | |
left: 0; | |
backface-visibility: hidden; | |
border-radius: 4px; | |
} | |
&:after { | |
content: attr(data-tg-on); | |
background: #02C66F; | |
transform: rotateY(-180deg); | |
} | |
&:before { | |
background: #FF3A19; | |
content: attr(data-tg-off); | |
} | |
&:active:before { | |
transform: rotateY(-20deg); | |
} | |
} | |
&:checked + .tgl-btn { | |
&:before { | |
transform: rotateY(180deg); | |
} | |
&:after { | |
transform: rotateY(0); | |
left: 0; | |
background: #7FC6A6; | |
} | |
&:active:after { | |
transform: rotateY(20deg); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment