为OPTION文本设置样式部分 [英] Styling part of the OPTION text

查看:255
本文介绍了为OPTION文本设置样式部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个OPTION元素的SELECT列表。这是我对样式部分选项文本的简洁方法:

I have a SELECT list with several OPTION elements. Here is my naive approach to styling part of the option text:

<select name="color">
<option value="0">red <span style="font-weight: bold;">SLOW</span></option>
<option value="1">blue <span style="font-weight: bold;">SLOWER</span></option>
<option value="2">green <span style="font-weight: bold;">SLOWEST</span></option>
</select>

这不起作用:浏览器不喜欢OPTION元素内的SPAN元素。

This does not work: the browser does not like a SPAN element inside the OPTION element.

是否有其他方法来为OPTION元素的文本设置样式部分?

Is there some other way to style part of an OPTION element's text?

推荐答案

没有。 选项的样式是以平台本地的方式,并且样式只有一部分的样式不起作用。 (通常也不是一个特别好的主意。)

Nope. options are styled in a way native to the platform, and styling only a part of one doesn't work. (It usually wouldn't be a particularly good idea either.)

这篇关于为OPTION文本设置样式部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆