How to style the select options ? i want alternating background colors in the drop down menu.
+2
A:
Just like any other element
option:nth-child(even) {
background-color: red;
}
option:nth-child(odd) {
background-color: blue;
}
If you need to support browsers that don't support nth-child
you'll need to use a class.
Some browsers don't support styling option
s at all (guess which ones).
RoToRa
2010-06-23 11:33:31
thanks a lot. how to limit the number of the items displayed ?
Harsha M V
2010-06-23 11:57:14
Not possible. That's up to the browser or even the operating system.
RoToRa
2010-06-23 14:57:28
A:
OK, if this is going the way of HTML/CSS, I might as well suggest a wonderful jQuery UI plugin called UI Selectmenu. It is the most wonderful thing I have seen about select menus so far. I bet you could easily implement alternating option colors with it.
But it's fair to say that this plugin is in development stage - proceed with caution!
Igor Zinov'yev
2010-06-23 11:38:32