tags:

views:

774

answers:

1

Hi everyone,

Is it Possible to keep the background-image for drop down box using CSS.

For Textbox is getting correctly.

can anybody give sample example

Thanks & Regards

Ravi Kumar

+2  A: 

Yes is possible. You can style the elements not the select box, as the select box gives only the line when you selected something.

try this css:

<style>
    .green { background:green}
    .red { background:red}
    .blue{background:blue}
</style>

and this html:

<form>
    <select class='green'>
        <option class='red'>A</option>
        <option class='blue'>B</option>
    </select>
</form>

You will see that the main line is green and the options are colored each one to its colour. You can also attach images to the background for each css class.

Elzo Valugi
The only caveat is that in FF, the selected element will take the colour of the `select` background, but in IE6, the selected element will have its own colour.
voyager
@voyager in my FF 3.5 the select always stays green.
Elzo Valugi