I'm using Select2 to style my <select>
boxes, but I can't seem to style the forced outline which Chrome applies to the style:
Problem:
I've tried several lines of (very unprofessionally, !important
) CSS code, but so far I haven't come up with the solution, this is what i'm at right now:
CSS:
.select2 > *:focus, .select2:focus .select2 > *, .select2 {
outline-width: 0px !important;
}
For the sake of excluding potential problems, i'm definitely including this CSS file, after my regular select2.css
Also, a fiddle would be problematic, but I could provide one if really necessary
$('#id'). select2('open'); will set focus and open the select2 ready for search. $('#id'). select2('focus'); will set the focus on select2 but not select2 will be not opened for search.
Even above in Shadows answer, you have to specify each select2 element to have the dropdown parent. So when the dropdown opens, select2-container--open is attached to the dropdown, the select2-selection__arrow will receive the transform css.
Adding the following is enough: . select2-container . select2-choice { height: 200px; } To have it apply only after an object is selected, add/modify the corresponding css on a change event or similar. This changes the height of the select2 input field, which is not what was asked for.
This seems to do the trick:
<style>
.select2-container *:focus {
outline: none;
}
</style>
Here is a plunk.
This works for me:
&.select2-container--focus {
outline: none;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With