Created
September 2, 2021 21:05
Star
You must be signed in to star a gist
Checkboxes and Radiobuttons
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>Test</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" /> | |
<style> | |
input[type="radio"] ~ label, | |
input[type="checkbox"] ~ label { | |
padding: 0; | |
margin-left: 20px; | |
} | |
input[type="radio"], | |
input[type="checkbox"] { | |
outline: none; | |
border: none !important; | |
margin: 0 !important; | |
width: 0px !important; | |
height: 0px !important; | |
-webkit-appearance: none; | |
} | |
input[type="radio"] + label, | |
input[type="checkbox"] + label { | |
width: auto; | |
font-weight: 400; | |
line-height: initial; | |
margin-bottom: 10px; | |
display: inline-block; | |
cursor: pointer; | |
padding-top: 0; | |
margin-left: 20px; | |
margin-right: 10px; | |
text-indent: -20px; | |
vertical-align: top; | |
} | |
input[type="radio"] + label::before, | |
input[type="checkbox"] + label::before { | |
font-family: "FontAwesome"; | |
border: 1px solid #CCCCCC; | |
background-color: #FFFFFF; | |
width: 1.563em; | |
height: 1.563em; | |
margin-right: 4px; | |
color: transparent; | |
line-height: 20px; | |
outline: 0px dotted #212121; | |
outline: 0px solid -webkit-focus-ring-color; | |
position: relative; | |
top: -1px; | |
} | |
input[type="checkbox"] + label::before { | |
content: "\f00c"; | |
font-size: 10px; | |
border-radius: 0; | |
padding: 2px; | |
} | |
input[type="radio"] + label::before { | |
content: "\f111"; | |
font-size: 10px; | |
border-radius: 50%; | |
padding: 2px 3px; | |
} | |
input[type="radio"]:focus + label::before, | |
input[type="checkbox"]:focus + label::before { | |
outline-width: 1px; | |
} | |
input[type="radio"]:checked + label::before, | |
input[type="checkbox"]:checked + label::before { | |
color: #000000; | |
} | |
input[type="radio"]:disabled + label::before, | |
input[type="checkbox"]:disabled + label::before { | |
border-color: #AAAAAA; | |
} | |
input[type="radio"]:checked:disabled + label::before, | |
input[type="checkbox"]:checked:disabled + label::before { | |
color: #AAAAAA; | |
border-color: #AAAAAA; | |
} | |
</style> | |
</head> | |
<body> | |
Genders: | |
<input id="rdoMale" value="Male" name="rdoGender" type="radio" /><label for="rdoMale">Male</label> | |
<input id="rdoFemale" value="Female" name="rdoGender" type="radio" /><label for="rdoFemale">FeMale</label> | |
<br /> | |
Genders: | |
<input id="chkMale" value="Male" name="chkGender" type="checkbox" /><label for="chkMale">Male</label> | |
<input id="chkFemale" value="Female" name="chkGender" type="checkbox" /><label for="chkFemale">FeMale</label> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment