您可以在选择字段中有多种字体颜色吗? [英] Can you have multiple font colors in select field?

查看:170
本文介绍了您可以在选择字段中有多种字体颜色吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以有一个HTML选择字段,其中OPTION文本的颜色不同?

 < select& 
< option> Black_text(yellow_text)< / option>
< / select>

我尝试使用CSS SPAN元素为文本着色,但似乎不工作。 / p>

有任何想法吗?



更新:请注意,字体颜色在相同选项行。我已经看到了很多关于如何设置整个 OPTION行的样式的教程,但是我想在相同选项行中设置样式。

解决方案

尝试为选项本身设置样式:

 < option style =...>标签< / option> 

但我怀疑浏览器支持这些元素的样式。






编辑


尝试在相同的选项行上有多种字体颜色。


这不可能作为 选项元素只允许文本作为内容:

 <!ELEMENT选项 -  O(#PCDATA) > 


Is it possible to have an HTML select field where the OPTION text is of different colors?

<select>
<option>Black_text (yellow_text)</option>
</select>

I tried using an CSS SPAN element to color the text but that doesn't seem to work.

Any ideas?

UPDATE: Note, I'm trying to have multiple font colors on the same OPTION row. I've seen quite a few tutorials on how to style the entire OPTION row but I'm trying to style elements within the same option row.

解决方案

Try to style the option elements itself:

<option style="…">Label</option>

But I doubt that browsers support much styling of these elements.


Edit

I'm trying to have multiple font colors on the same OPTION row.

That’s not possible as the option element does only allow text as content:

<!ELEMENT OPTION - O (#PCDATA)         -- selectable choice -->

这篇关于您可以在选择字段中有多种字体颜色吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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