在 chrome 中选择粗体的下拉选项 [英] Select dropdown option bold in chrome

查看:23
本文介绍了在 chrome 中选择粗体的下拉选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以使用 CSS 在 Chrome 和 IE 中的 select 框中使 标记加粗?它在 Firefox 中工作.

Is there any way to make an <option> tag bold in a select box in Chrome and IE using CSS? It's working in Firefox.

option.red {
    background-color: #cc0000; 
    font-weight: bold; 
    font-size: 12px; 
    color: white;
}

<select name="color">
    <option class="red" value="red">Red</option>
    <option value="white">White</option>
    <option value="blue">Blue</option>
    <option value="green">Green</option>
</select>

这是与此处相同的问题,但没有答案.

This is the same question as here, but there was no answer.

推荐答案

您不能这样做.您会在那里"找到的最有可能的解决方案是添加具有硬编码样式的周围跨度,但 IE (7) 和 Firefox (3.0.12) 都不支持这一点.

You cannot do this. The most likely solution you'll find "out there" would be to add a surrounding span with hard coded style, but neither IE (7) nor Firefox (3.0.12) honor this.

您可以做的是使用 JavaScript 解决方案为您提供选择的外观,而无需实际使用选择.

What you can do is use a JavaScript solution to give you the appearance of a select without actually using a select.

这里有一个很好的操作方法":http://www.devirtuoso.com/2009/08/styling-drop-down-boxes-with-jquery/

And here's a great "howto" on how to do it: http://www.devirtuoso.com/2009/08/styling-drop-down-boxes-with-jquery/

这篇关于在 chrome 中选择粗体的下拉选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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