html - Align label with css 3 fancy radio button -
i have following radio button, need bigger circle 38px
input[type=radio] { visibility: hidden; } .label { font-weight: normal; color: #333; } .label::before { content: ''; position: absolute; left: 0; width: 38px; height: 38px; border: 1px solid #727272; border-radius: 50%; } input[type=radio]:checked+label:after { content: ''; position: absolute; width: 38px; height: 38px; left: 0; background: #0065bd; border: none; transform: scale(0.5); border-radius: 50%; }
<div class="container"> <input type="radio" id="radio1" value="on"> <label for="radio1" class="label">yes</label> </div>
here fiddle, how can align label aligned centered , pushed right of circle?
perhaps code over-complicating matters; want input bigger, maybe should focus sizing etc on input rather label?
see snippet (the radio turns blue since edit, adapted this codepen. it's grey before click, blue after, centered, , indented edge).
just note: if going use default value (and have 1 option) maybe custom checkbox more suitable choice? (radios button used in instances user have 2 or more choices, can select one).. thought.
input[type="radio"] { display: none; width: 38px; height: 38px; border: 1px solid #727272; } input[type="radio"]+label span { display: inline-block; width: 38px; height: 38px; margin: 9px; vertical-align: middle; cursor: pointer; border-radius: 50%; background-color: grey; } input[type="radio"]:checked+label span { content=""; background: #0065bd; } input[type="radio"]+label span, input[type="radio"]:checked+label span { -webkit-transition: background-color 0.4s linear; -o-transition: background-color 0.4s linear; -moz-transition: background-color 0.4s linear; transition: background-color 0.4s linear; }
<div class="container"> <input type="radio" id="radio1" name="radio"> <label for="radio1" class="label"><span></span>yes</label> <input type="radio" id="radio2" name="radio"> <label for="radio2" class="label"><span></span>no</label> </div>
Comments
Post a Comment