Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two columns on same row with bootstrap 3.2

I'm trying to place two columns on the same row with Bootstrap 3.2, but am not having any success.

The format that I want is something like this: BeginDate: txbox1 EndDate: txtbox2

My code is as follows, but I know it's incorrect.

I would appreciate it very much for someone more experienced in Bootstrap for a solution.

<label for="dteBeginDate" class="col-md-2 control-label">Begin Date:</label>
                <div class="col-md-10">
                    <input type="date" id="dteBeginDate">
                </div>
                <label for="dteEndDate" class="col-md-2 control-label">End Date:</label>
                <div class="col-md-10">
                    <input type="date" id="dteEndDate">
                </div>
like image 363
sagesky36 Avatar asked Dec 12 '22 04:12

sagesky36


2 Answers

Bootstrap 3 has a 12 unit width column grid, so this means that each row can have up to 12 columns, and additional columns will be stacked below as another rows. You are setting 24 units (col-md-2 + col-md-10 + col-md-2 + col-md-10), so the second pair of columns are moving to another row (remember that the number post-fix in the class names indicates the column length). Reduce the units to 12, placing them within a "row" class div for completeness (it doesn't constraint that all the elements will be within a single row, though). For example:

<div class="row">
  <label for="dteBeginDate" class="col-md-2 control-label">Begin Date:</label>
  <div class="col-md-4">
    <input type="date" id="dteBeginDate">
  </div>
  <label for="dteEndDate" class="col-md-2 control-label">End Date:</label>
  <div class="col-md-4">
    <input type="date" id="dteEndDate">
  </div>
</div>
like image 81
Guillermo Gutiérrez Avatar answered Dec 13 '22 17:12

Guillermo Gutiérrez


enter image description here

Demo: http://jsbin.com/yukut/1/edit

I think what you are looking for is the form-inline. Look at the docs: http://getbootstrap.com/css/#forms

   <form class="form-inline" role="form">
      <div class="form-group">
        <label for="begin_date">Begin Date:</label>
        <input type="date" class="form-control" id="begin_date" placeholder="Start Date">
      </div>
      <div class="form-group">
        <label for="end_date">End Date:</label>
        <input type="date" class="form-control" id="end_date" placeholder="End Date">
      </div>
    </form>
like image 20
Christina Avatar answered Dec 13 '22 16:12

Christina