Last active
July 29, 2021 11:03
-
-
Save Murmurianez/fb7834389ed08afaa333 to your computer and use it in GitHub Desktop.
Simple CSS + SVG checkbox and radiobox
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
<style> | |
.checkbox{ | |
margin: 10px 20px; | |
input[type=checkbox] { | |
display:none; | |
} | |
input[type=checkbox] + label{ | |
border: 2px solid #FFFFFF; | |
outline: 2px solid #000000; | |
height: 16px; | |
width: 16px; | |
display:inline-block; | |
padding: 0; | |
cursor: pointer; | |
} | |
input[type=checkbox]:checked + label{ | |
background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAlElEQVQ4T6WTXQ2AMAwGDwdIQAISQAEWsIQCQAkWkIAEJJCSNCljP7Dtdblb26+rKDxVIU+uoAY2YMoRKNwC61/BAwbGP4IXLPP7KvDCVtAARyCRIKyCBRiAHtgdSRRWwQjMwOlIkrBtwZVIO5LzHZVMO7RwdohWIoIk7EtBJXIXfVkr8sUoki5Wtm3n6x4E/1yx4AI+qiERKNFzCwAAAABJRU5ErkJggg==") #FFFFFF; | |
height: 16px; | |
width: 16px; | |
display:inline-block; | |
padding: 0; | |
} | |
.checkbox-text{ | |
position: relative; | |
font-family: Arial; | |
font-size: 14px; | |
padding: 0 6px; | |
top: -4px; | |
cursor: pointer; | |
} | |
} | |
.radio{ | |
margin: 10px 20px; | |
input[type=radio] { | |
display:none; | |
} | |
input[type=radio] + label{ | |
border: 2px solid #000000; | |
/* outline: 2px solid #000000; */ | |
height: 18px; | |
width: 18px; | |
display:inline-block; | |
padding: 0; | |
cursor: pointer; | |
border-radius: 50%; | |
} | |
input[type=radio]:checked + label{ | |
background:#000000; | |
height: 14px; | |
width: 14px; | |
display:inline-block; | |
padding: 2px; | |
box-shadow: inset 0 0 0 4px #FFFFFF; | |
} | |
.radio-text{ | |
position: relative; | |
font-family: Arial; | |
font-size: 14px; | |
padding: 0 6px; | |
top: -5px; | |
cursor: pointer; | |
} | |
} | |
</style> | |
<div class="checkbox"> | |
<input type='checkbox' name='thing1' value='valuable' id="thing1"/> | |
<label for="thing1"></label> | |
<label for="thing1" class="checkbox-text">Checkbox</label> | |
</div> | |
<div class="checkbox"> | |
<input type='checkbox' name='thing2' value='valuable' id="thing2"/> | |
<label for="thing2"></label> | |
<label for="thing2" class="checkbox-text">Checkbox</label> | |
</div> | |
<div class="checkbox"> | |
<input type='checkbox' name='thing3' value='valuable' id="thing3"/> | |
<label for="thing3"></label> | |
<label for="thing3" class="checkbox-text">Checkbox</label> | |
</div> | |
<div class="radio"> | |
<input type='radio' name='thing' value='valuable' id="radio1"/> | |
<label for="radio1"></label> | |
<label for="radio1" class="radio-text">Radio</label> | |
</div> | |
<div class="radio"> | |
<input type='radio' name='thing' value='valuable' id="radio2"/> | |
<label for="radio2"></label> | |
<label for="radio2" class="radio-text">Radio</label> | |
</div> | |
<div class="radio"> | |
<input type='radio' name='thing' value='valuable' id="radio3"/> | |
<label for="radio3"></label> | |
<label for="radio3" class="radio-text">Radio</label> | |
</div> |
This is base64 isn't it ? Not SVG
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsfiddle.net/Murmurianez/rb4698qb/