最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - MultiColumn HTML List Box - Stack Overflow

programmeradmin5浏览0评论

Is it possible to create a List Box, with List Items in Multiple Columns? I am aware of the alternatives, but I am wondering if this is possible in <select>

Is it possible to create a List Box, with List Items in Multiple Columns? I am aware of the alternatives, but I am wondering if this is possible in <select>

Share Improve this question asked Sep 6, 2010 at 10:17 StarxStarx 79.1k50 gold badges187 silver badges265 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

No, it is not. The only allowed child-tag for select is option, which itself can only contain plain-text (but some browsers support some style-tags here, like b or i etc.).

The only pseudo-solution I can think of is using a fixed-width font for the list dropdown and then padding the content columns with spaces.

 COL1_NAME         |  COL2_NAME
 Some nice value   |  Another value
 Another nice value|  Second column

You can even try using "OPTGROUP" elements for the column names, but you have to be aware of different formattings applied by different browsers.

Update: For instance you can create a "multi-column" dropdown as seen here: http://twitpic./2lsuxx with the following HTML

<style type="text/css">* {font-family:Courier New;white-space:pre;}</style>
<select>
  <option></option>
  <optgroup label="      Col1              | Col2">
    <option>Some nice value   |  Another value</option>
    <option>Another nice value|  Second column</option> 
  <optgroup>
</select>
发布评论

评论列表(0)

  1. 暂无评论