问题
When I use a multiple
select2 element, it very short show a vertical scrollbar (HTML Select) until the ready()
is called and the element is changed.
This can even be observed at the website https://select2.org/getting-started/basic-usage. If you scroll to the multiple-combobox, and hit Refresh you very shortly see the traditional scrollbar on the right.
Is there a way to prevent this?
Thanks
回答1:
The issue is because the default select
element is overflowed. This is why you see the scrollbar on it for a fraction of a second before the Select2 plugin loads and injects the new elements.
To fix this you can add a overflow: hidden
CSS rule to the select
elements which you instantiate Select2 on, so that this scrollbar is never shown, no matter how briefly. Note that this will render the select
element unusable if Select2 fails to load, though.
回答2:
I found a solution: add visibility: hidden;
to the <select>
style/CSS.
来源:https://stackoverflow.com/questions/61508688/select2-shows-flashing-multiple-scrollbar-until-ready