选项文本的样式部分 [英] Styling part of the OPTION text
本文介绍了选项文本的样式部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含多个 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?
推荐答案
不.option
以平台原生的方式设置样式,仅设置其中一部分的样式是行不通的.(这通常也不是一个特别好的主意.)
Nope. option
s 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.)
这篇关于选项文本的样式部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文