Skip to content

Instantly share code, notes, and snippets.

@ramsesoriginal
Created March 7, 2012 12:47
Show Gist options
  • Save ramsesoriginal/1992917 to your computer and use it in GitHub Desktop.
Save ramsesoriginal/1992917 to your computer and use it in GitHub Desktop.
Switches
/**
* Switches
*/
@import url(http://fonts.googleapis.com/css?family=Maven+Pro:900,400,500,700);
@import url(http://fonts.googleapis.com/css?family=Economica:400,700);
* {
box-sizing: border-box;
transition: all 0.5s ease;
}
html, body {
min-height: 100%;
margin:0;
padding:0;
border:0;
otline:0;
}
body {
background-color: hsl(0,0%,18%);
background-size: 8px 8px;
background-image: radial-gradient( #555 0px, hsla(0,0%,0%,0) 2px, hsla(0,0%,0%,0) 24px), repeating-radial-gradient( #666 0px, black 2px, black 48px);
}
.switch
{
display: none;
}
fieldset ,
legend,
ol {
margin:0;
padding:0;
border:0;
otline:0;
}
form, ol{
display: box;
box-orient: horizontal;
}
li, fieldset{
display: block;
box-flex: 1;
}
fieldset {
margin: 30px 15px;
box-shadow: inset 0px 2px 3px 2px #222, inset 1px 1px 2px 1px #555;
background-color: #aaa;
padding: 2px;
}
legend {
padding: 0.5em 1em;
color: #aaa;
border-radius: 1em;
background-color: #aaa;
background-image:linear-gradient( 0deg, hsla(0,0%,0%,0) 0, hsla(0,0%,10%,1) 3px),linear-gradient( 90deg, hsla(0,0%,0%,0) 0, hsla(0,0%,10%,1) 5px);
box-shadow: 15px 5px 5px 0px rgba(0, 0, 0, 0.5), inset 0px 0px 5px 0px rgba(0, 0, 0, 1), inset 1px 1px 2px 1px #555;
font-family: 'Maven Pro', sans-serif;
font-weight: bold;
position: relative;
z-index: 10;
}
ol {
margin-top: -1em;
}
label {
padding: 1em 0;
display: block;
background-image: linear-gradient(top, rgba(174,188,191,0.3) 0%,rgba(110,119,116,0.3) 50%,rgba(10,14,10,0.3) 51%,rgba(10,8,9,0.3) 100%);
font-family: 'Economica', sans-serif;
font-weight: bold;
text-transform:uppercase;
}
li {
text-align: center;
}
li:not(:first-child) {
border-left: 1px solid black;
}
li:not(:last-child) {
border-right: 1px solid black;
}
li .yes {
background-color: #D8D1B4;
padding-left: 0;
padding-right: 0;
}
li .no {
background-color: #862424;
padding-left: 0;
padding-right: 0;
color: #aaa;
}
li .no:before, li .no:after {
color: #aaa;
}
li .none {
background-color: #F1F0E9;
padding-left: 0;
padding-right: 0;
}
fieldset:not(:hover) li:not(:first-child) .no:checked ~ .no:before,
fieldset:not(:hover) li:not(:first-child) .none:checked ~ .none:before,
fieldset:not(:hover) li:not(:first-child) .yes:checked ~ .yes:before,
li:not(:first-child):hover label:before{
content: '\AB ';
font-family: 'Maven Pro', sans-serif;
font-weight: bold;
}
fieldset:not(:hover) li:not(:last-child) .no:checked ~ .no:after,
fieldset:not(:hover) li:not(:last-child) .none:checked ~ .none:after,
fieldset:not(:hover) li:not(:last-child) .yes:checked ~ .yes:after,
li:not(:last-child):hover label:after{
content: ' \BB';
font-family: 'Maven Pro', sans-serif;
font-weight: bold;
}
fieldset:not(:hover) .no:checked ~ .no,
fieldset:not(:hover) .none:checked ~ .none,
fieldset:not(:hover) .yes:checked ~ .yes,
li:hover label {
padding-left: 2.5em;
padding-right: 2.5em;
}
<form>
<fieldset>
<legend>First Option</legend>
<ol>
<li>
<input type="radio" id="first_yes" name="first" class="switch yes" />
<label for="first_yes" class="yes">yes</label>
</li>
<li class="no">
<input type="radio" id="first_no" name="first" class="switch no" />
<label for="first_no" class="no">no</label>
</li>
</ol>
</fieldset>
<fieldset>
<legend>Second Option</legend>
<ol>
<li>
<input type="radio" id="second_yes" name="second" class="switch yes" />
<label for="second_yes" class="yes">yes</label>
</li>
<li>
<input type="radio" id="second_no" name="second" class="switch no" />
<label for="second_no" class="no">no</label>
</li>
</ol>
</fieldset>
<fieldset>
<legend>Third Option</legend>
<ol>
<li>
<input type="radio" id="third_yes" name="third" class="switch yes" />
<label for="third_yes" class="yes">yes</label>
</li>
<li>
<input type="radio" id="third_no" name="third" class="switch no" />
<label for="third_no" class="no">no</label>
</li>
</ol>
</fieldset>
<fieldset>
<legend>Fourth Option</legend>
<ol>
<li>
<input type="radio" id="fourth_yes" name="fourth" class="switch yes" />
<label for="fourth_yes" class="yes">yes</label>
</li>
<li>
<input type="radio" id="fourth_no" name="fourth" class="switch no" />
<label for="fourth_no" class="no">no</label>
</li>
<li>
<input type="radio" id="fourth_none" name="fourth" class="switch none" />
<label for="fourth_none" class="none">none</label>
</li>
</ol>
</fieldset>
</form>
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"result"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment