Created
July 4, 2014 16:18
-
-
Save danprince/dc0036909774ef8603d5 to your computer and use it in GitHub Desktop.
Checkbox to Yes/No in Pure CSS
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> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<input type='checkbox'/> | |
</body> | |
</html> |
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
.pill() { | |
border-radius:4px; | |
padding:4px 12px; | |
font-size:1.3em; | |
whitespace:nowrap; | |
min-width:32px; | |
text-align:center; | |
cursor:pointer; | |
} | |
input[type='checkbox'] { | |
height:0; | |
display:inline-block; | |
cursor:pointer; | |
&:after { | |
content: 'Yes'; | |
background:#ddd; | |
color:#888; | |
.pill() | |
} | |
&:before { | |
background:#4fd1e7; | |
color:white; | |
content: 'No'; | |
margin-right:4px; | |
.pill() | |
} | |
&:checked { | |
&:after { | |
background:#4fd1e7; | |
color:white; | |
} | |
&:before { | |
background:#ddd; | |
color:#888; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment