Skip to content

Instantly share code, notes, and snippets.

@rowlandekemezie
Created January 17, 2018 18:52
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 rowlandekemezie/00cb8ac40e8418b3bf0eede64054cbdf to your computer and use it in GitHub Desktop.
Save rowlandekemezie/00cb8ac40e8418b3bf0eede64054cbdf to your computer and use it in GitHub Desktop.
My CSS trick in creating a custom radio button
input[type="radio"] {
position: absolute;
left: -9999px;
}
.label {
display: block;
position: relative;
margin-left: 0;
padding: 3px 0 3px 25px;
cursor: pointer;
font-size: 14px;
&::before, &::after {
content: '';
position: absolute;
top: 0;
left: 0;
}
&::before {
display: block;
width: 20px;
height: 20px;
border: .2rem solid #2B7DB6;
box-sizing: border-box;
}
&::after {
display: none;
width: 12px;
height: 12px;
margin: 4px;
background-color: #2B7DB6;
}
}
input[type="radio"] + label::before,
input[type="radio"] + label::after {
border-radius: 50%;
}
input:checked + label::after {
display: block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment