Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide optgroup label?

I need to get rid of labels in optgroups.

From this: http://i.stack.imgur.com/Gn5e5.png

Into this: http://i.stack.imgur.com/ZvRM7.png

But I need to do this with opgroups. I don`t want to delete them.

<select>
  <optgroup>
    <option>1</option>
  </optgroup>
  <optgroup>
    <option>2</option>
  </optgroup>
  <optgroup>
    <option>3</option>
  </optgroup>
  <optgroup>
    <option>4</option>
  </optgroup>
</select>

Jsfiddle: http://jsfiddle.net/upXn8/

like image 499
Adam Avatar asked Nov 26 '22 18:11

Adam


2 Answers

this is better, try it!

optgroup {
        color: transparent;
        height: 0px;
    }

    optgroup option {
        color: inherit;
    }
like image 72
JsWizard Avatar answered Nov 29 '22 06:11

JsWizard


you can use the same color as the optgroup background and set another color for option

optgroup{
    color:white;
}

optgroup option{
    color:black;
}
like image 22
clie Avatar answered Nov 29 '22 06:11

clie