How do I change the width of a select field, when using Twitter bootstrap? Adding input-xxlarge
CSS classes doesn't seem to work (like it does on other form elements), so the elements in my drop down are currently cut off.
7 Answers
This works for me to reduce select tag's width;
<select id ="Select1" class="input-small">
You can use any one of these classes;
class="input-small"
class="input-medium"
class="input-large"
class="input-xlarge"
class="input-xxlarge"

- 2,010
- 1
- 25
- 30
-
29Just want to note that this doesn't work in bootstrap 3. These classes now only have an effect on the height/padding of the control. – Stefan Aug 21 '13 at 21:18
-
14For twitter bootstrap 3, add: .input-mini { width: 60px; } .input-small { width: 90px; } .input-medium { width: 150px; } .input-large { width: 210px; } .input-xlarge { width: 270px; } .input-xxlarge { width: 530px; } – Jeroen K Aug 30 '13 at 13:43
-
1a responsible (dynamic) solution would be nice – Stef Hej Jan 07 '17 at 23:31
I did a workaround by creating a new css class in my custom stylesheet as follows:
.selectwidthauto
{
width:auto !important;
}
And then applied this class to all my select elements either manually like:
<select id="State" class="selectwidthauto">
...
</select>
Or using jQuery:
$('select').addClass('selectwidthauto');

- 1,955
- 5
- 37
- 64
-
1This is a good solution. But when 3 drop-down menus are added together, this still makes these 3 drop-down menus stack. – Wayne Liu Jan 30 '15 at 09:52
-
1I don't if you still need help three years later, bur for those coming you can add display:inline-block so they don't stack – Zachary Weixelbaum Jan 10 '18 at 22:03
In bootstrap 3, it is recommended that you size inputs by wrapping them in col-**-#
div tags. It seems that most things have 100% width, especially .form-control
elements.

- 1,011
- 1
- 17
- 30

- 209
- 2
- 2
You can use something like this
<div class="row">
<div class="col-xs-2">
<select id="info_type" class="form-control">
<option>College</option>
<option>Exam</option>
</select>
</div>
</div>

- 317
- 5
- 10
For me Pawan's css class combined with display: inline-block (so the selects don't stack) works best. And I wrap it in a media-query, so it stays Mobile Friendly:
@media (min-width: $screen-xs) {
.selectwidthauto {
width:auto !important;
display: inline-block;
}
}

- 71
- 1
- 3
Tested alone, <select class=input-xxlarge>
sets the content width of the element to 530px. (The total width of the element is slightly smaller than that of <input class=input-xxlarge>
due to different padding. If this a a problem, set the paddings in your own style sheet as desired.)
So if it does not work, the effect is prevented by some setting in your own style sheet or maybe in the use other settings for the element.

- 195,524
- 37
- 270
- 390
with bootstrap use class input-md = medium, input-lg = large, for more info see https://getbootstrap.com/docs/3.3/css/#forms-control-sizes
-
This has only effect on the height of the `select` element, not the width. – McVenco Nov 28 '17 at 12:56