Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using colors in dropdown-boxes.

Status
Not open for further replies.

Petal

Programmer
Jun 8, 2001
56
NO
Hi

I would like to make a dropdownbox with these elements:
1 - green
2 - blue
3 - red
4 - gray
etc..

I have made this code;
<option style=&quot;background-color: #00FF00&quot; value=1>1 - green</option>

etc..
My problem is that I would only the word of the color (&quot;green&quot; or something) to have the background-color. I would that the number should have a white background-color.

I thougt about doing this using background-image. But I dont think this will work.

Any suggestions?

Jørn Arild Andenæs
jaa@jaa.no
 
try something like this
<style>
option.red {background-color: red; font-weight: bold; font-size: 12px; color: white;}
option.green {background-color: green; font-weight: bold; font-size: 12px; color: white;}
option.blue {background-color: blue; font-weight: bold; font-size: 12px; color: white;}
option.gray {background-color: gray; font-weight: bold; font-size: 12px; color: white;}
</style>
<select>
<option class=&quot;red&quot;>red
<option class=&quot;green&quot;>green
<option class=&quot;blue&quot;>blue
<option class=&quot;gray&quot;>gray
</select> You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
this is actually what you wanted isn't it
<style>
option.red {background-color: white; font-weight: bold; font-size: 12px; color: red;}
option.green {background-color: white; font-weight: bold; font-size: 12px; color: green;}
option.blue {background-color: white; font-weight: bold; font-size: 12px; color: blue;}
option.gray {background-color: white; font-weight: bold; font-size: 12px; color: gray;}
</style>
<select>
<option class=&quot;red&quot;>one
<option class=&quot;green&quot;>two
<option class=&quot;blue&quot;>three
<option class=&quot;gray&quot;>four
</select>

I think????
thgeres both ways anyhow You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
Hi

Thanks for the tips. But is not actually what I wanted.
I will try to explaine it again.
I would have black text-color on the text, both at the number and the color. On the numbers I would have white background, and on the color-text i would have colored background.

Is it possible to do this?
Jørn Arild Andenæs
jaa@jaa.no
 
I tried and tried as I might but I couldn't get two different background colors in the list. Maybe someone else has the answer. Sorry You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top