How can I apply table structure to select box options in HTML

末鹿安然 提交于 2019-12-11 00:18:54

问题


In my select box options, each option having three words.Now I want apply fixed widths for each word of the option so that the all options will come as i required for example My options are as follows :

1,   aaaaa bbbbb ccccccccc
2,   aaaaaaaa bbbbbbb cccc     
3,   aaaaaa bbbbb cccc 

but i want to display these options in the dropdown as

1,   aaaaa     bbbbb     ccccccccc
2,   aaaaaaaa  bbbbbbb   cccc     
3,   aaaaaa    bbbbb     cccc 

help me if anyone know how to do this


回答1:


you can use div and CSS style .See this sample that i wrote in jsfiddle.net
See example




回答2:


One possibility would be to 1) apply a monospace font to select options, and 2) use JavaScript to make sure each element of an option has the same number of characters by adding trailing spaces as needed, either to some arbitrary length or to the length of the longest element.




回答3:


Another option might be to use a third-party JavaScript library to restructure the select box and add styling as needed.

http://ivaynberg.github.com/select2/



来源:https://stackoverflow.com/questions/15434633/how-can-i-apply-table-structure-to-select-box-options-in-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!