简体   繁体   中英

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

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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