Search code examples
htmlcssflexboxtwitter-bootstrap-4

How to place radio buttons at the right end of the row using bootstrap 4?


Now I tried classes .pull-right and .float-right to place my radio buttons at the right end. Its not working. Coding and Picture below.

<div class="row ">
  <div class="form-group col-lg-6">
    <div class="row">
      <label class="Bold">Is Valid</label> 
      <input class="radio-inline float-right" type="radio">Yes 
      <input class="radio-inline float-right"  type="radio" >No
    </div>
  </div>
  <div class="form-group col-lg-6">
    <div class="row">
      <label class="Bold">Is Checked</label> 
      <input class="radio-inline float-right" type="radio">Yes 
      <input class="radio-inline float-right"  type="radio" >No
    </div>
   </div>                                                                                                                
</div>

Screenshot

I want like the below image(just a sample)


Solution

  • You will need to wrap your radio buttons to a div .form-group and use [bootstrap4 flex utilities] classes d-flex justify-content-between to align them

    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
    <div class="container">
      <div class="row ">
        <div class="form-group col-lg-6">
          <div class="d-flex justify-content-between">
            <label class="Bold">Is Valid</label>
            <div class="form-group">
              <input class="radio-inline" type="radio">Yes
              <input class="radio-inline" type="radio">No
            </div>
          </div>
        </div>
        <div class="form-group col-lg-6">
          <div class="d-flex justify-content-between">
            <label class="Bold">Is Checked</label>
            <div class="form-group">
              <input class="radio-inline" type="radio">Yes
              <input class="radio-inline" type="radio">No
            </div>
          </div>
        </div>
      </div>
    </div>