I am looking to build multiple html select elements with custom background colors for each option:
<select runat="server" id="select">
<option value="A">White</option>
<option value="B">Red</option>
<option value="C">Yellow</option>
<option value="D">Green</option>
When the website loads, I would like the select element to display only the background color and no text for the selected option. The text (white, red,....) should only be visible when the dropdown is opened.
As the selected value is changed by the user, the background color should change as well while the text should be invisible in the closed dropdown.
It would be really nice if the solution works on most browsers including IE 9/10.
Cheers.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…