How to style a select tag's option element?

前端 未结 6 1588
渐次进展
渐次进展 2020-11-22 11:03

I\'m trying to set the style of an option in a select dropdown menu in Google Chrome. It works in all browsers except IE9 and Chrome.

6条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 11:13

    It's a choice (from browser devs or W3C, I can't find any W3C specification about styling select options though) not allowing to style select options.

    I suspect this would be to keep consistency with native choice lists.
    (think about mobile devices for example).

    3 solutions come to my mind:

    • Use Select2 which actually converts your selects into uls (allowing many things)
    • Split your selects into multiple in order to group values
    • Split into optgroup

提交回复
热议问题