How do I force an input to stay on the same line as its label with Bootstrap form-control class?

Doug Johnson

I'm trying to force a <label/> and its <input/> to stay on the same line.

I'm using the form-control class to make the <input/> pretty. However, when I do so, it REALLY wants to put itself on a separate line. I'm avoiding using rows and columns because I want the label right next to the textbox, not to move around depending on the size of the screen.

  <div>
    <label class="form-label">Search</label>
    <input type="text" class="form-control">
  </div>

I want this:

Search [______________________]

I get this:

Search

[_____________________]

How do I force them to stay on the same line?

http://embed.plnkr.co/qA2s5RGRpvfRa7rhiq1n/preview

Aibrean

What you are looking for is referred by Bootstrap as an inline form or horizontal form.

<form class="form-inline" role="form">
  <div class="form-group">
    <label class="form-label">Search</label>
    <input type="text" class="form-control">
  </div>
 </form>

Make sure your form has the form-inline class on it and realistically they should be wrapped in a form-group. The inline form make everything in one line.

<form class="form-horizontal" role="form">
  <div class="form-group">
    <label class="col-sm-2 control-label">Search</label>
     <div class="col-sm-10">
       <input type="text" class="form-control">
    </div>
  </div>
 </form>

When using form-horizontal, the form-group acts like a row, so you can move content to separate lines :) With that, you would need to use grid properties so the label/input is properly aligned.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I force an input to stay on the same line as its label with Bootstrap form-control class?

From Dev

How do I make my post content stay within its bootstrap well, or limit line length?

From Dev

Select form and its label in same line in bootstrap3

From Dev

How do I force all ul elements to stay in one line?

From Dev

Force radio button and its label to be on same line

From Java

How to make <label> and <input> appear on the same line on an HTML form?

From Dev

How do I add a the bootstrap 'form-control' class to a select using the Simple_Form gem?

From Dev

How to force a really long word to stay on the same line as an image?

From Dev

How do I keep a form and its children centred, but have a label stick to the top left corner of my text input?

From Dev

How do I align the label and input in a one line?

From Dev

How do I align the label and input in a one line?

From Dev

How to make the bootstrap class="label label-default" same width as the input

From Dev

Using bootstrap why do these label and input controls not show up on the same line

From Dev

Force image to stay on the same line as text

From Dev

Force image to stay on the same line as text

From Dev

How to get class="form-control" in input fields by default (Rails Form Helper + Bootstrap 3)

From Dev

How do I communicate with a control of a Form from another class?

From Dev

How do i align all these Read Mores in the same line in bootstrap

From Dev

How do I get the form to be on the same line as by navigation buttons?

From Dev

How can I align my buttons so that they stay in the same line?

From Dev

On jquery fadeIn, how can i make it such that they will stay on the same line?

From Dev

how to use form control class in bootstrap templates?

From Dev

What does Bootstrap's control-label class do?

From Dev

How do I force `gpg2` to always produce the same output for the same input?

From Dev

How do I get a Bootstrap container to stay inline with another div?

From Dev

label and input in same line on mobile

From Dev

Button in same line as input and label

From Dev

How do I make these HTML blocks of info stay the same size?

From Dev

Bootstrap 3.2: Button group and input group on same line in form

Related Related

  1. 1

    How do I force an input to stay on the same line as its label with Bootstrap form-control class?

  2. 2

    How do I make my post content stay within its bootstrap well, or limit line length?

  3. 3

    Select form and its label in same line in bootstrap3

  4. 4

    How do I force all ul elements to stay in one line?

  5. 5

    Force radio button and its label to be on same line

  6. 6

    How to make <label> and <input> appear on the same line on an HTML form?

  7. 7

    How do I add a the bootstrap 'form-control' class to a select using the Simple_Form gem?

  8. 8

    How to force a really long word to stay on the same line as an image?

  9. 9

    How do I keep a form and its children centred, but have a label stick to the top left corner of my text input?

  10. 10

    How do I align the label and input in a one line?

  11. 11

    How do I align the label and input in a one line?

  12. 12

    How to make the bootstrap class="label label-default" same width as the input

  13. 13

    Using bootstrap why do these label and input controls not show up on the same line

  14. 14

    Force image to stay on the same line as text

  15. 15

    Force image to stay on the same line as text

  16. 16

    How to get class="form-control" in input fields by default (Rails Form Helper + Bootstrap 3)

  17. 17

    How do I communicate with a control of a Form from another class?

  18. 18

    How do i align all these Read Mores in the same line in bootstrap

  19. 19

    How do I get the form to be on the same line as by navigation buttons?

  20. 20

    How can I align my buttons so that they stay in the same line?

  21. 21

    On jquery fadeIn, how can i make it such that they will stay on the same line?

  22. 22

    how to use form control class in bootstrap templates?

  23. 23

    What does Bootstrap's control-label class do?

  24. 24

    How do I force `gpg2` to always produce the same output for the same input?

  25. 25

    How do I get a Bootstrap container to stay inline with another div?

  26. 26

    label and input in same line on mobile

  27. 27

    Button in same line as input and label

  28. 28

    How do I make these HTML blocks of info stay the same size?

  29. 29

    Bootstrap 3.2: Button group and input group on same line in form

HotTag

Archive