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.

enter image description here

so did few things code:

  1. align items inside label using inline-blocks:

    .radio label > span {     display: inline-block;     vertical-align: middle; } 

    this better positioning using px.

  2. 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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -