Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 button-group and input-group in one row

If you have a look at the following example, you can see that the input-group is below the button-group:

http://bootply.com/81723

I already tried putting both groups into floating divs, but the browsers still break the row. I noticed that ".btn-group, .btn-group-vertical" contain a "display: inline-block". After commenting this line out, the row doesn't break, but I don't have a space between both div (although I thought to get one by "padding-right: 16px")

like image 733
IT KFV Avatar asked Sep 18 '13 12:09

IT KFV


People also ask

How do I make two buttons in one line in Bootstrap?

How do you put two buttons on the same line? If you have multiple buttons that should sit side-by-side on the same line, add the data-inline="true" attribute to each button. This will style the buttons to be the width of their content and float the buttons so they sit on the same line.

How do I make two buttons side by side in Bootstrap?

You can use an out div with a class btn-group . This helps to align the buttons horizontally. Using col-md-6 for each button div can make the buttons missaligned with unwanted space in between.

What is the difference between form group and input group?

Using input groups you can easily prepend and append text or buttons to the text-based inputs. For example, you can add the $ symbol, @ for a Twitter username, or anything else as required. Form groups are used to wrap labels and form controls in a div to get optimum spacing between the label and the control.

How multiple buttons can be created at once in Bootstrap?

Instead of applying button sizing classes to every button in a group, just add .btn-group-* to each .btn-group , including each one when nesting multiple groups.


1 Answers

Found a working solution using table-display for containers:

<div class="Toolbar">
<div>
    <div class="btn-group">
        <button id="ButtonCreate" class="btn btn-default btn-sm" onclick="CreateItem()" title="Erstellen"><span class="glyphicon glyphicon-file"></span></button>
        <button id="ButtonUpdate" class="btn btn-default btn-sm" onclick="UpdateItem()" title="Bearbeiten"><span class="glyphicon glyphicon-pencil"></span></button>
        <button id="ButtonDelete" class="btn btn-default btn-sm" onclick="DeleteItems()" title="L&ouml;schen"><span class="glyphicon glyphicon-trash"></span></button>
        <button id="ButtonExport" class="btn btn-default btn-sm" onclick="ExportItems()" title="Exportieren"><span class="glyphicon glyphicon-export"></span></button>
    </div>
</div>

<div>
    <div class="input-group input-group-sm">
        <span class="input-group-btn"><button id="ButtonSearch" class="btn btn-default btn-sm" onclick="SearchItem()" title="Suchen"><span class="glyphicon glyphicon-search"></span></button></span>
        <input type="text" class="form-control" style="width: 300px;" placeholder="Suchen">
    </div>
</div>
</div>

CSS (LESS):

.Toolbar
{
  position: relative;
  display: table;
}

.Toolbar > div
{
  display: table-cell;
  padding-right: 8px;
  vertical-align: top;
}

.Toolbar
{
  .btn-group, .btn-group-vertical
  {
    vertical-align: inherit;
  }
}
like image 157
IT KFV Avatar answered Nov 11 '22 22:11

IT KFV