简体   繁体   English

样式下拉菜单项具有不同的颜色

[英]Style dropdown items with different colors

I'm trying to style each option in a dropdown with a different color. 我正在尝试为下拉菜单中的每个选项设置不同的颜色。 I've tried two approaches: 我尝试了两种方法:

<option style="color: red;" value="KellerWilliamsRed">Keller Williams Red</option>

And... 和...

<option class="dilbeck" value="DilbeckGreen">Dilbeck Green</option>
.dilbeck {color: green}

For some reason though, the text is not colored, and I'm stumped... 但是由于某种原因,文本没有着色,我很困惑...

You can see the dropdown here: http://dailyspiro.com/lp/LP.html 您可以在此处查看下拉列表: http : //dailyspiro.com/lp/LP.html

Here's a FIDDLE 这是一块

select option:nth-child(1) {
  color: red;
}
select option:nth-child(2) {
  color: blue;
}
select option:nth-child(3) {
  color: green;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM