How can I change color of a select option with CSS on hover?

前端 未结 3 2078
别跟我提以往
别跟我提以往 2021-01-23 05:45

                        
    
提交评论

  • 2021-01-23 06:21

    Styling select and option tag is very limited.

    This is because the way they are displayed may change according to the browser/the OS. Think about what happens when you click a select tag on your phone. You don't get a dropdown list as expected on a desktop browser. So you couldnt style something universal as it doesn't natively display the save everywhere.

    Styling possibilities are: mainly on the select tag but very restricted on the option. You could for example disable the native style of the select box:

    select {
        appearance: none;
        /* may need vendors prefixes. */
    }
    

    Other solution is: jQuery plugins that simulate select box using other HTML tags:

    • https://jqueryui.com/selectmenu/
    • https://github.com/marcj/jquery-selectBox
    • And all that Google may return you with keywords "jQuery select box" :)
    0 讨论(0)
  • 2021-01-23 06:21

    Option elements are rendered by the OS, not HTML. You cannot change the style for these elements.

    0 讨论(0)
  • 提交回复
    热议问题