html - Aligning Bootstrap Radio Buttons with text -
i trying radio buttons align having difficulty doing this. trying have buttons align indentation because going display caret if option has been selected. want text come bit because it's not inline actual radio button.
input[type=radio] { z-index: 3; width: 26px; height: 26px; -moz-appearance: none; } label { font-weight: normal; font-size: 1.5em; cursor: pointer; } .question-label { margin-left: 15px; }
<div class="radio"> <label> <span class="button"><input type="radio" name="optionsradios" value="20"></span> <span class="question-label">true</span> </label> </div> <div class="radio"> <label> <span><i class="fa fa-caret-right fa-2x correct-answer" aria-hidden="true"></i></span> <span class="button"><input type="radio" name="optionsradios" value="20"></span> <span class="question-label">false</span> </label> </div>
here looks right now.
so did few things code:
align items inside
label
usinginline-block
s:.radio label > span { display: inline-block; vertical-align: middle; }
this better positioning using
px
.now add caret icon both
radio
horizontal alignment automatically done (and can contextually show green caret). make work apply these:.correct-answer { color: green; } .wrong-answer { opacity: 0; }
let me know feedback. thanks!
input[type=radio] { z-index: 3; width: 26px; height: 26px; -moz-appearance: none; } label { font-weight: normal; font-size: 1.5em; cursor: pointer; } .question-label { margin-left: 15px; } .radio label > span { display: inline-block; vertical-align: middle; } .correct-answer { color: green; } .wrong-answer { opacity: 0; }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"> <div class="radio"> <label> <span><i class="fa fa-caret-right fa-2x wrong-answer" aria-hidden="true"></i></span> <span class="button"><input type="radio" name="optionsradios" value="20"></span> <span class="question-label">true</span> </label> </div> <div class="radio"> <label> <span><i class="fa fa-caret-right fa-2x correct-answer" aria-hidden="true"></i></span> <span class="button"><input type="radio" name="optionsradios" value="20"></span> <span class="question-label">false</span> </label> </div>
Comments
Post a Comment