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 - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -