Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap radio button text group

I would like to group the radio button and bootstrap select but they're not inline.

<div class="container">
            <form class="form-inline">
            <div class="input-group">
            <label class="radio-inline">
              <input name="radioGroup" id="radio1" value="option1" type="radio"><span class="input-group-addon"> Preset Size (<b>inch</b>): 
            </span></label>
              <div class="col-md-6">
              <select id="size" class="selectpicker form-control" data-live-search="true" title="Please select preset size ...">
                    <option>36” x 84”</option>
                    <option>48”x84”</option>
                    <option>60”x84”</option>
                    <option>72x84”</option>
                    <option>48”x96”</option>
                </select>
              </div>
            </div> <!-- Radio + Dropdown -->
            </form>
            </div> <!-- container -->

and I also want to group 2 text boxes together with the label to create user input.

<div class="container">
            <form class="form-inline">
            <div class="input-group">
            <label class="radio-inline">
              <input name="radioGroup" id="radio2" value="option2" checked="" type="radio"> Custom Size: 
            </label>
            <div class="col-sm-4">
              <input type="text" class="form-control" id="customSize1" placeholder="">
            </div>
            <div class="col-sm-4">
              <label> x </label>
             </div> 
            <div class="col-sm-4">
              <input type="text" class="form-control" id="customSize2" placeholder="">
            </div>
            </div>
          </form>
          </div>

Here's the output screenshot.

enter image description here

like image 712
user3744076 Avatar asked Dec 04 '25 18:12

user3744076


1 Answers

You may need to re-arrange your code a bit to fit bootstrap's use.

Firstly, use .form-group - also put element in rows when possible.

Something along the lines of:

ps you may have to adjust this a bit but it should give you a good place to start from

.form-inline input.form-control {
  width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />


<div class="container">
  <form class="form-inline">
    <div class="row">
      <div class="form-group col-xs-6">
        <label class="radio-inline col-xs-6">
          <input name="radioGroup" id="radio1" value="option1" type="radio" />Preset Size (<b>inch</b>):
        </label>
        <div class="col-xs-5">
          <select id="size" class="selectpicker form-control" data-live-search="true" title="Please select preset size ...">
            <option>36”x84”</option>
            <option>48”x84”</option>
            <option>60”x84”</option>
            <option>72x84”</option>
            <option>48”x96”</option>
          </select>
        </div>

      </div>
      <div class="form-group col-xs-6">
        <label class="radio-inline col-xs-5">
          <input name="radioGroup" id="radio2" value="option2" checked="" type="radio">Custom Size:
        </label>
        <div class="col-xs-3">
          <input type="text" class="form-control" id="customSize1" placeholder="">
        </div>
        <div class="col-xs-1">
          <label>x</label>
        </div>
        <div class="col-xs-3">
          <input type="text" class="form-control" id="customSize2" placeholder="">
        </div>
      </div>

    </div>
  </form>
</div>
like image 93
blurfus Avatar answered Dec 06 '25 10:12

blurfus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!