CSS with Option tag - Editing text color

后端 未结 2 1733
栀梦
栀梦 2021-01-25 00:09

Is there any secret behind editing a option tag with css? I just can\'t solve this issue

相关标签:
2条回答
  • 2021-01-25 00:52

    I know this question is old, but there are some new developments in the world of CSS!

    color property on select will now set color of option(s) text (including selected), while adding / over-riding color to select option.

    CSS:

    select {
      color: white; /* color of selected option */
     }
    
    select option {
      color: black; /* color of other options */
    }
    
    0 讨论(0)
  • 2021-01-25 01:04

    <option> elements cannot contain anything other than text. So no, you can't apply a style to a section of their content.

    Just don't use a <select>, or don't bother about styling. From your use case, it doesn't really look suitable anyway. It'd be better just to type the name, wouldn't it?

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