Over a million developers have joined DZone.

Styling a Chosen select to fit Bootstrap 3 better

· Java Zone

Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience, brought to you in partnership with JetBrains

One project that I'm currently working on is an internal business application that's using stock Bootstrap 3. I needed a searchable select box and Chosen fitted the bill, so I'm using that.

However, the default styles for the Chosen select box differ slightly from Bootstrap. The most noticeable being the height of the control.

To fix this, I added this CSS:

.chosen-container-single .chosen-single {
    height: 30px;
    border-radius: 3px;
    border: 1px solid #CCCCCC;
.chosen-container-single .chosen-single span {
    padding-top: 2px;
.chosen-container-single .chosen-single div b {
    margin-top: 2px;

I also noticed that a focussed Bootstrap 3 element has a blue outline, but the Chosen select doesn't. To fix this, I added:

.chosen-container-active .chosen-single,
.chosen-container-active.chosen-with-drop .chosen-single {
    border-color: #ccc;
    border-color: rgba(82, 168, 236, .8);
    outline: 0;
    outline: thin dotted \9;
    -moz-box-shadow: 0 0 8px rgba(82, 168, 236, .6);
    box-shadow: 0 0 8px rgba(82, 168, 236, .6)

Chosen before

Chosen after

Update: Brian Ridley pointed me at bootstrap-chosen which is much more comprehensive.

Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.


Published at DZone with permission of Rob Allen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}