选择Multiple Html with columns - 可能吗?

SB2*_*055 2 javascript css jquery html5 css3

我正在努力实现以下目标:

<select ...>
  <option>Column 1     Column 2</option>
  <option>Line 1       Data 1</option>
  <option>Line 2       Data 2</option>
  <option>Line 3       Data 3</option>
  <option>...          ...</option>
  <option>Line n       Data n</option>
</select>
Run Code Online (Sandbox Code Playgroud)

不使用固定宽度的字体.我有一个选项+描述,我想为每个选项显示<select multiple />.

这是可能的直接css/html,还是我需要寻找一个插件?

hex*_*D49 5

第一个代码段适用于两列选择列表,而第二个代码段可以处理多个列.分号;用作分隔符.

// two-column multiple select list
window.onload = function(){
  var s = document.getElementsByTagName('SELECT')[0].options, 
      l = 0, 
      d = '';
  for(i = 0; i < s.length; i++){
    if(s[i].text.length > l) l = s[i].text.length; 
  }
  for(i = 0; i < s.length; i++){
    d = '';  
    line = s[i].text.split(';');
    l1 = (l - line[0].length);
    for(j = 0; j < l1; j++){
      d += '\u00a0'; 
    }
    s[i].text = line[0] + d + line[1];
  }  
};
Run Code Online (Sandbox Code Playgroud)

工作jsBin

// multiple-column multiple select list
window.onload = function(){

  var s = document.getElementsByTagName('SELECT')[1].options, l = [];

  for(i = 0; i < s.length; i++){
    column = s[i].text.split(';');
    for(j = 0; j < column.length; j++){
      if(!l[j]) l[j] = 0;
      if(column[j].length > l[j]){
        l[j] = column[j].length;
      }      
    }    
  }  

  for(i = 0; i < s.length; i++){
    column = s[i].text.split(';');
    temp_line = '';
    for(j = 0; j < column.length; j++){
      t = (l[j] - column[j].length);
      d = '\u00a0';
      for(k = 0; k < t; k++){
        d += '\u00a0';
      }
      temp_line += column[j] + d;
    }
    s[i].text = temp_line;    
  }  

};
Run Code Online (Sandbox Code Playgroud)

工作jsBin