我可以将HTML选择选项文本分组到列中

时间:2021-11-04 22:29:59

I have an HTML select options with text I would like to group into columns that are aligned. I tried using inline-block:

我有一个带有文本的HTML选择选项,我想将它们分组到对齐的列中。我尝试使用内联块:

<select>
  <option><span div="display:inline-block;width:3em;">A:</span><span style="display:inline-block;width:5em;">Lorem Ipsum</span>
  </option>
  <option><span div="display:inline-block;width:3em;">AA:</span><span style="display:inline-block;width:5em;">Fusce efficitur ante</span>
  </option>
</select>

I want to get the output:

我想获得输出:

A   Lorem Ipum
AA  Fusce efficitur ante

Is there any Twitter Bootstrap for this?

这是否有任何Twitter Bootstrap?

1 个解决方案

#1


1  

Unfortunately, we can't set the style for option element, except to background-color and color.

不幸的是,除了背景颜色和颜色之外,我们无法为选项元素设置样式。

But we can try to use &nbsp; and monospaced font like courier.

但我们可以尝试使用 和monospaced字体一样快递。

select, option {
  font-family: courier;
}
<select>
  <option>A:&nbsp;&nbsp;Lorem Ipsum</option>
  <option>AA:&nbsp;Fusce efficitur ante</option>
</select>

#1


1  

Unfortunately, we can't set the style for option element, except to background-color and color.

不幸的是,除了背景颜色和颜色之外,我们无法为选项元素设置样式。

But we can try to use &nbsp; and monospaced font like courier.

但我们可以尝试使用 和monospaced字体一样快递。

select, option {
  font-family: courier;
}
<select>
  <option>A:&nbsp;&nbsp;Lorem Ipsum</option>
  <option>AA:&nbsp;Fusce efficitur ante</option>
</select>