问题
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