Skip to content

Instantly share code, notes, and snippets.

@ruedap
Last active August 29, 2015 14:07
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 ruedap/fb404d8cf8d2d4cc5775 to your computer and use it in GitHub Desktop.
Save ruedap/fb404d8cf8d2d4cc5775 to your computer and use it in GitHub Desktop.
CSS3 custom radio button
input[type=radio] {
display: none;
& + label {
position: relative;
padding-left: 24px;
cursor: pointer;
&::before,
&::after {
position: absolute;
content: '';
top: 50%;
left: 0;
display: block;
}
&::before {
width: 18px;
height: 18px;
margin-top: -9px;
background-color: #fff;
border: 2px solid #ccc;
border-radius: 50%;
}
}
&:checked + label::after {
left: 5px;
width: 8px;
height: 8px;
margin-top: -4px;
background-color: #000;
border-radius: 50%;
}
}
%div
= f.radio_button :hoge, :yes
= f.label :hoge, 'hoge yes', value: :yes
%div
= f.radio_button :hoge, :no
= f.label :hoge, 'hoge no', value: :no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment