如何在select标记中创建分隔符?
New Window
New Tab
-----------
Save Page
------------
Exit
发布于 2014-04-24 02:15:23
禁用选项方法似乎看起来是最好的,也是最受支持的。我还提供了一个使用optgroup的示例。
optgroup (这种方式有点糟糕):
<select>
<optgroup>
<option>First</option>
</optgroup>
<optgroup label="_________">
<option>Second</option>
<option>Third</option>
</optgroup>
</select>
禁用选项(更好一点):
<select>
<option>First</option>
<option disabled>_________</option>
<option>Second</option>
<option>Third</option>
</select>
如果你真的想变得花哨,那就使用水平unicode框来绘制字符。
(最佳选择!)
<select>
<option>First</option>
<option disabled>──────────</option>
<option>Second</option>
<option>Third</option>
</select>
发布于 2009-05-22 18:01:02
尝试:
<optgroup label="----------"></optgroup>
发布于 2016-01-17 08:41:58
这是一个旧的线程,但由于没有人发布类似的响应,因此我将添加此内容,因为这是我首选的分离方式。
我发现使用破折号之类的东西有点难看,因为它可能会比选择框的宽度小。因此,我更喜欢使用CSS来创建分隔符。一个简单的背景着色。
<select>
<option style="background-color: #cccccc;" disabled selected>Select An Option</option>
<option>First Option</option>
<option>Second</option>
<option style="font-size: 1pt; background-color: #000000;" disabled> </option>
<option>Third</option>
<option>Fourth</option>
<option style="font-size: 1pt; background-color: #000000;" disabled> </option>
<option>Fifth</option>
<option>Sixth</option>
</select>
https://stackoverflow.com/questions/899148
复制相似问题