berkanakyurek / select2-bootstrap4-theme

A theme for Select2 v4 and Bootstrap 4
https://berkan52.github.io/select2-bootstrap4-theme/
MIT License
91 stars 41 forks source link

Set select-box width to 100% or auto #1

Closed odahcam closed 6 years ago

odahcam commented 6 years ago

Select2 sets the element with to a size in pixels, but in Bootstrap, by default, all inputs are 100% width, save in exception the checkbox, radius, etc for obvius reasons. 😆

berkanakyurek commented 6 years ago

You're right. I usually use it like this:

`

`

Joyrex commented 6 years ago

Select2's own docs say the best way to ensure proper width is to set width: 100% via a style attribute on the original select element, but if the w-100 class works, then great!

odahcam commented 6 years ago

All right, but if I'm using form control, I expect the field to be 100% width, as it would be in Bootstrap 4 or 3. Also, styleattribute is not a good practice.

ambrosiora commented 6 years ago

Hy everyone,

I'm just sharing with you all the only way I fix that:

span.select2-container{
    width: auto !important;
}

I'm not sure if it is the best way, but works fine ;)