Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@afraser
Created August 2, 2012 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afraser/3238598 to your computer and use it in GitHub Desktop.
Save afraser/3238598 to your computer and use it in GitHub Desktop.
Toggle switch
/**
* Toggle switch
*/
*{
box-sizing: border-box;
}
input, textarea{
box-sizing: content-box;
}
body{
background: white;
}
label.toggle {
position: relative;
display: block;
padding: 6px 0;
height: 38px;
width: 200px;
margin-bottom: 10px;
cursor: pointer;
}
label.toggle input {
position: absolute;
opacity: 0;
}
label.toggle input &:focus + span{
outline: 1px dotted #fff;
}
label.toggle input:checked + span {
left: 0%;
}
/* Track background*/
label.toggle:before {
content: '';
position: absolute;
top: 0;
z-index: 0;
width: 100%;
height: 100%;
padding: 0px;
background-color: rgba(0, 0, 0, 0.02);
border-radius: 4px;
box-shadow: inset 0 1px 1px 1px rgba(0, 0, 0, 0.3), 0 1px 0px rgba(255, 255, 255, 0.2);
}
/* Text labels*/
label.toggle::after {
position: relative;
font-family: Helvetica;
font-size: 14px;
line-height: 1em;
color: #333;
text-shadow: 0 1px 0 #FFF;
z-index: 2;
float: right;
padding: 0.5em 0;
white-space: pre;
text-align: center;
/*width: 197px;*/
/*content: attr(data-off) "\a" attr(data-on);*/
width: 188px;
content: attr(data-off) " " attr(data-on);
}
/* Switch*/
label.toggle span{
display: block;
position: absolute;
left: 50%;
top: 0;
z-index: 1;
width: 50%;
height: 100%;
margin: 0px;
background-image: linear-gradient(top, #f6f6f6, #e5e5e5);
border: 1px solid #B4B4B4;
border-radius: 3px;
transition: left 0.3s ease-out;
}
<label class="toggle toggle_smartnotes" data-on="SmartNotes" data-off="Full Text">
<input type="checkbox" checked="checked">
<span/>
</label>
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment