Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using input-group inside an inline form

When appending an input-group to a form-inline, the input-group appears below the form on a "new line" instead of inline with the other controls.

It seems that this is because the input-group wrapper class has display set to table whereas the other inputs, which work fine, have their display set to inline-block. Of course, it is not possible to give the input-group the inline-block display because its child add-on span, which has display: table-cell, needs the property of the parent to align correctly.

So my question is: is it possible to use input-group inside an inline form using Bootstrap classes exclusively? If not, what would be the best work-around allowing the use of custom classes.

Here is a demo illustrating my point. The code is the following:

<form action="" class="form-inline">     <input type="text" class="form-control" placeholder="Works with" style="width: 100px;"/>     <input type="text" class="form-control" placeholder="Text Inputs" style="width: 120px;"/>      <div class="checkbox">         <label>             <input type="checkbox" /> and Checkboxes         </label>     </div>     <select class="form-control" style="width: 150px;">         <option>and Selects</option>     </select>      <button type="submit" class="btn btn-default">and Buttons</button>     <div class="input-group" style="width: 220px;">         <span class="input-group-addon">BUT</span>         <input type="text" class="form-control" placeholder="not with input-groups" />     </div> </form> 
like image 497
edsioufi Avatar asked Aug 12 '13 14:08

edsioufi


People also ask

How do I make a group inline form?

to make it simple, just add a class="form-inline" before the input.

What is input group append?

input-group class is a container to enhance an input by adding an icon, text or a button in front or behind the input field as a "help text". Use . input-group-prepend to add the help text in front of the input, and . input-group-append to add it behind the input.

What is the difference between input group and form 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.

Which class can be used to display inline form?

Inline forms Use the . form-inline class to display a series of labels, form controls, and buttons on a single horizontal row. Form controls within inline forms vary slightly from their default states.

What are the inputs of an inline form?

The inputs contain the placeholder attribute to specify the field description. Forms with inline elements are one of the efficient ways of designing web forms. Why do we need to display Bootstrap inline forms?

Why does the input-group appear below the form-inline?

5 When appending an input-groupto a form-inline, the input-groupappears below the form on a "new line" instead of inline with the other controls. It seems that this is because the input-groupwrapper class has displayset to tablewhereas the other inputs, which work fine, have their displayset to inline-block.

Is it possible to use input-group inside an inline form using bootstrap?

Of course, it is not possible to give the input-groupthe inline-blockdisplay because its child add-onspan, which has display: table-cell, needs the property of the parent to align correctly. So my question is:is it possible to use input-groupinside an inline form using Bootstrap classes exclusively?

How do I add help text to an input group?

The .input-group class is a container to enhance an input by adding an icon, text or a button in front or behind the input field as a "help text". Use .input-group-prepend to add the help text in front of the input, and .input-group-append to add it behind the input.


1 Answers

This was indeed a bug and was resolved (check the issue on github for more info).

From now on the inline forms in BootStrap require to wrap the child form controls with .form-group.

So my code would become:

<form action="" class="form-inline">     <div class="form-group">         <input type="text" class="form-control" placeholder="Works with" style="width: 100px;"/>     </div>      ...     <div class="form-group">         <div class="input-group" style="width: 220px;">             <span class="input-group-addon">BUT</span>             <input type="text" class="form-control" placeholder="not with input-groups" />         </div>     </div> </form> 
like image 200
edsioufi Avatar answered Oct 10 '22 11:10

edsioufi