Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to achieve a "mini" select style using Bootstrap (or straight CSS)?

I'm using Bootstrap's btn-mini class for "mini" buttons and am looking for something analogous to create a "mini" select element, where the select button (i.e. the part you click to show the list of options, not the list of options itself) is the same size and style as a mini button.

When I apply the btn-mini class to a select element, the font style of the select button is the same size as a mini button, but the size of the select button itself is unchanged from the default size.

Is there a different Bootstrap class I should use? Or another way to do it?

P.S. I'm working on OS X Chrome, but naturally hope there is a cross-browser compatible solution.

like image 292
Ghopper21 Avatar asked Aug 27 '12 20:08

Ghopper21


2 Answers

Just in case any Bootstrap 3 users come across this old question, here's the BS3 way:

<select class="form-control input-lg"></select> <select class="form-control"></select> <select class="form-control input-sm"></select>  <input class="form-control input-lg"> <input class="form-control"> <input class="form-control input-sm"> 

There is no input-xs, though, so you'd have to make that yourself if you wanted smaller.

.input-xs, select.input-xs {   height: 20px;   line-height: 20px; } 
like image 139
Will Stern Avatar answered Oct 06 '22 05:10

Will Stern


HTML

<select class="btn btn-mini">     <!-- options --> </select> <span class="caret"></span> 

CSS

select.btn-mini {     height: auto;     line-height: 14px; }  /* this is optional (see below) */ select.btn {     -webkit-appearance: button;        -moz-appearance: button;             appearance: button;     padding-right: 16px; }  select.btn-mini + .caret {     margin-left: -20px;     margin-top: 9px; } 

The last 2 rules are optional, it will make <select> look like <button>, I've also added a caret to it. See this fiddle.

like image 24
Pavlo Avatar answered Oct 06 '22 05:10

Pavlo