Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap: wider input field

How can I make the input field wider than the default in Twitter's Bootstrap?

I am trying to create a wider search form in the hero-unit class from the example.

like image 364
yayu Avatar asked Mar 20 '12 10:03

yayu


People also ask

How do you change the width of an input-group?

To set the width of the input-group-text , just change the value of the flex of the input-group , for instance, as seen above 30% of the total width.

How do I change the width of a form control in bootstrap 5?

Just use the 'size' property of input.


6 Answers

There are various classes for different size inputs

 :class=>"input-mini"

 :class=>"input-small"

 :class=>"input-medium"

 :class=>"input-large"

 :class=>"input-xlarge"

 :class=>"input-xxlarge"
like image 143
user1449337 Avatar answered Oct 13 '22 21:10

user1449337


Use the bootstrap built in classes input-large, input-medium, ... : <input type="text" class="input-large search-query">

Or use your own css:

  1. Give the element a unique classname class="search-query input-mysize"
  2. Add this in your css file (not the bootstrap.less or css files):
    .input-mysize { width: 150px }
like image 45
ChrisR Avatar answered Oct 13 '22 20:10

ChrisR


in bootstrap 3.0 :

Set heights using classes like .input-lg, and set widths using grid column classes like .col-lg-*.

Example:

<div class="row">
    <div class="col-xs-2">
        <input type="text" class="form-control" placeholder=".col-xs-2">
    </div>
    <div class="col-xs-3">
        <input type="text" class="form-control" placeholder=".col-xs-3">
    </div>
    <div class="col-xs-4">
        <input type="text" class="form-control" placeholder=".col-xs-4">
    </div>
</div>

Source: http://getbootstrap.com/css/#forms-control-sizes

like image 27
LGama Avatar answered Oct 13 '22 20:10

LGama


I made a wider input field by using either span4 or span6 as class.

<input type="text" class="span6 input-large search-query">

This way you don't need the additional custom css, mentioned earlier.

like image 34
Andra Avatar answered Oct 13 '22 20:10

Andra


There is also a smaller one yet called "input-mini".

like image 28
Paito Avatar answered Oct 13 '22 19:10

Paito


I am going to assume you were having the same issue I was. Even though you specify larger sizes for the TextBox and mark it as important, the box would not get larger. That is likely because in your site.css file the MaxWidth is being set to 280px.

Add a style attribute to your input to remove the MaxWidth like this:

<input type="text"  style="max-width:none !important" class="input-medium">
like image 27
Brad Avatar answered Oct 13 '22 20:10

Brad