Skip to content

Instantly share code, notes, and snippets.

@mitchmccline
Created May 13, 2013 04:17
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 mitchmccline/5566124 to your computer and use it in GitHub Desktop.
Save mitchmccline/5566124 to your computer and use it in GitHub Desktop.
A CodePen by mitchmc. CSS only Custom Radio and Checkboxes - Based on the webdesign tuts+ article (link below) but instead of using images I used only css. http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-easy-css3-checkboxes-and-radio-buttons/
<div>
<input type="checkbox" id="check01" name="check" />
<label for="check01"><span></span>Check Box 1</label>
</div>
<div>
<input type="checkbox" id="check02" name="check" />
<label for="check02"><span></span>Check Box 2</label>
</div>
<div>
<input type="checkbox" id="check03" name="check" />
<label for="check03"><span></span>Check Box 3</label>
</div>
<div>
<input type="radio" id="radio01" name="radio" />
<label for="radio01"><span></span>Radio Button 1</label>
</div>
<div>
<input type="radio" id="radio02" name="radio" />
<label for="radio02"><span></span>Radio Button 2</label>
</div>
@import "compass";
$DarkBrown: #292321;
$Orange: #CC3300;
div {
margin:0 0 0.75em 0;
}
input[type="checkbox"],
input[type="radio"] {
display:none;
}
input[type="checkbox"] + label,
input[type="radio"] + label {
color: $DarkBrown;
font-family:Arial, sans-serif;
font-size:14px;
}
input[type="checkbox"] + label span,
input[type="radio"] + label span {
display:inline-block;
width:19px;
height:19px;
margin:-1px 4px 0 0;
vertical-align:middle;
cursor:pointer;
-moz-border-radius: 50%;
border-radius: 50%;
}
input[type="checkbox"] + label span,
input[type="radio"] + label span {
background-color:$DarkBrown;
}
input[type="checkbox"]:checked + label span,
input[type="radio"]:checked + label span{
background-color:$Orange;
}
input[type="checkbox"] + label span,
input[type="checkbox"]:checked + label span,
input[type="radio"] + label span,
input[type="radio"]:checked + label span {
-webkit-transition:background-color 0.4s linear;
-o-transition:background-color 0.4s linear;
-moz-transition:background-color 0.4s linear;
transition:background-color 0.4s linear;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment