Skip to content

Instantly share code, notes, and snippets.

Created January 23, 2017 21:58
Show Gist options
  • Save anonymous/107f8a4fb156c393cf0422a0c99cc567 to your computer and use it in GitHub Desktop.
Save anonymous/107f8a4fb156c393cf0422a0c99cc567 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/zelasiw
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.togglePill.togglePill-true:after {
background-position: 0px;
width: 40px;
animation: showhide 0.3s;
}
.togglePill.togglePill-false:after {
background-position: -53px;
width: 40px;
animation: hideshow 0.3s;
}
.togglePill.togglePill-true:after {
padding-right: 15px;
content: "True";
}
.togglePill.togglePill-false:after {
content: "False";
}
.togglePill {
background-color: #00e600;
width: 60px;
border: 2px solid #00e600;
border-radius: 5px;
box-shadow: 1px 1px 5px #888;
cursor: pointer;
color: white;
transition: background-color 0.3s, border-color 0.3s;
transition-timing-function: ease-in-out;
}
.togglePill:after {
border-radius: 5px;
background: linear-gradient(to right, #00e600 90%, white 10%);
background-repeat: repeat-y;
transition: background-position 0.3s;
transition-timing-function: ease-in-out;
padding: 0 10px;
}
.togglePill.togglePill-true {
background-color: #00e600;
border-color: #00e600;
}
.togglePill.togglePill-false {
background-color: red;
border-color: red;
}
@keyframes hideshow,
@keyframes showhide{
0% {color: rgba(0, 230, 0, 0);}
89% {color: rgba(0, 230, 0, 0);}
90% {color: rgba(0, 230, 0, 1);}
}
</style>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.0.0.js"></script>
<div class="togglePill togglePill-true">
</div>
<script id="jsbin-javascript">
$('.togglePill').click(function() {
$(this).toggleClass('togglePill-true')
.toggleClass('togglePill-false')
})
</script>
<script id="jsbin-source-css" type="text/css">.togglePill.togglePill-true:after {
background-position: 0px;
width: 40px;
animation: showhide 0.3s;
}
.togglePill.togglePill-false:after {
background-position: -53px;
width: 40px;
animation: hideshow 0.3s;
}
.togglePill.togglePill-true:after {
padding-right: 15px;
content: "True";
}
.togglePill.togglePill-false:after {
content: "False";
}
.togglePill {
background-color: #00e600;
width: 60px;
border: 2px solid #00e600;
border-radius: 5px;
box-shadow: 1px 1px 5px #888;
cursor: pointer;
color: white;
transition: background-color 0.3s, border-color 0.3s;
transition-timing-function: ease-in-out;
}
.togglePill:after {
border-radius: 5px;
background: linear-gradient(to right, #00e600 90%, white 10%);
background-repeat: repeat-y;
transition: background-position 0.3s;
transition-timing-function: ease-in-out;
padding: 0 10px;
}
.togglePill.togglePill-true {
background-color: #00e600;
border-color: #00e600;
}
.togglePill.togglePill-false {
background-color: red;
border-color: red;
}
@keyframes hideshow,
@keyframes showhide{
0% {color: rgba(0, 230, 0, 0);}
89% {color: rgba(0, 230, 0, 0);}
90% {color: rgba(0, 230, 0, 1);}
}</script>
<script id="jsbin-source-javascript" type="text/javascript">$('.togglePill').click(function() {
$(this).toggleClass('togglePill-true')
.toggleClass('togglePill-false')
})</script></body>
</html>
.togglePill.togglePill-true:after {
background-position: 0px;
width: 40px;
animation: showhide 0.3s;
}
.togglePill.togglePill-false:after {
background-position: -53px;
width: 40px;
animation: hideshow 0.3s;
}
.togglePill.togglePill-true:after {
padding-right: 15px;
content: "True";
}
.togglePill.togglePill-false:after {
content: "False";
}
.togglePill {
background-color: #00e600;
width: 60px;
border: 2px solid #00e600;
border-radius: 5px;
box-shadow: 1px 1px 5px #888;
cursor: pointer;
color: white;
transition: background-color 0.3s, border-color 0.3s;
transition-timing-function: ease-in-out;
}
.togglePill:after {
border-radius: 5px;
background: linear-gradient(to right, #00e600 90%, white 10%);
background-repeat: repeat-y;
transition: background-position 0.3s;
transition-timing-function: ease-in-out;
padding: 0 10px;
}
.togglePill.togglePill-true {
background-color: #00e600;
border-color: #00e600;
}
.togglePill.togglePill-false {
background-color: red;
border-color: red;
}
@keyframes hideshow,
@keyframes showhide{
0% {color: rgba(0, 230, 0, 0);}
89% {color: rgba(0, 230, 0, 0);}
90% {color: rgba(0, 230, 0, 1);}
}
$('.togglePill').click(function() {
$(this).toggleClass('togglePill-true')
.toggleClass('togglePill-false')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment