HTML / CSS: Nested in a <select> field?

后端 未结 5 456
醉话见心
醉话见心 2020-12-10 03:31

Is it possible to create nested option fields in a form drop down, much like you would create nested ul lists?

Since the change is just aesthetical, is it possible t

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 04:21

    Look into using the optgroup tag. As for styling support, there is some, but you are at the mercy of the browser as to how far you can take it as it is a form element.

    http://www.456bereastreet.com/lab/styling-form-controls-revisited/select-single-optgroup/

    If you need extensive restyling, consider building your own UI widget using perhaps a nested UL structure and giving it the interaction via JavaScript.

提交回复
热议问题