html - Styling selected option -


this question has answer here:

pretty self explaining, need style option selected user. possible without javascript?

simple example:

html:

<select multiple>     <option class="opt1" value="">option 1</option>     <option class="opt2" value="">option 2</option> </select> 

css:

.opt1[selected]{     background-color: red; } .opt2{     background-color: green; } 

js fiddle example

try .

<style> .your-select option:checked {background:#333;padding:20px;width:100px;border:3px solid #f00} </style>   <select multiple class="your-select">     <option class="opt1" value="">option 1</option>     <option class="opt2" value="">option 2</option> </select> 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -