Last active
August 29, 2015 14:07
-
-
Save ruedap/fb404d8cf8d2d4cc5775 to your computer and use it in GitHub Desktop.
CSS3 custom radio button
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
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%; | |
} | |
} |
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
%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