Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

style select option using css

Tags:

html

jquery

css

I'm trying to style a select option list using CSS. I want more padding between the times of the list because the seem squashed together. I've tried adding padding to the option element, but this doesn't seem to work. ANy ideas?

Here's my code

HTML

<select name="secondSelect[]" id='second' multiple='multiple' size='8' >
   <option value="1" style="padding: 10px;">Option a 1</option>
   <option value="2" SELECTED >Option b 2(sel)</option>
   <option value="3">Option c 3</option>
   <option value="4" SELECTED >Option d 4 (sel)</option>
   <option value="5">Option e 5</option>
   <option value="6">Option f 6</option>
   <option value="7">Option g 7</option>
   <option value="8">Option h 8</option>
   <option value="9">Option i 9</option>
   <option value="10" SELECTED >Option l 10 (sel)</option>
</select>​

CSS

.ms2side__div select {
    width: 220px;
    float: left;
    border: 1px solid #BFBFBF;
    background: white;
    font-size: 12px;
    color: #9D9D9D;
    font-family: Arial, Helvetica, sans-serif; 
    padding: 10px;
    line-height: 25px;
}​

http://jsfiddle.net/noscirre/GUdhc/

like image 970
user1038814 Avatar asked Dec 27 '25 21:12

user1038814


1 Answers

you can try <optgroup> tag:

<optgroup>
        <option value="1">Option a 1</option> 
</optgroup>

optgroup {
   padding: 5px 0px
}

http://jsfiddle.net/GUdhc/5/

like image 148
undefined Avatar answered Dec 30 '25 12:12

undefined