Select2 shows flashing 'multiple' scrollbar until ready()

可紊 提交于 2020-05-16 22:00:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!