【发布时间】:2015-08-16 10:04:31
【问题描述】:
我正在尝试设置<option> 标签的样式,以便在选择选项时基本上没有样式。原因是它是“duallist box”所以我真的不需要样式。
I've been able to set the background color (white) but when the select menu is focused, it sets the color of the options text to white as well.
我尝试在选择菜单和选项上设置颜色。我试过使用伪选择器。我在select 和option 标签上都尝试过内联样式。我似乎无法弄清楚。这显然是可能的,因为该链接具有我正在寻找的功能,尽管类似的 css 在我的应用程序中似乎不起作用。
如果有帮助,我会将 Wordpress 管理部分中的自定义字段设置为插件。除了这种风格,一切都正常。
目前也在 Chrome 上。虽然最终最好使用跨浏览器解决方案。
这是我尝试过的一些规则。除了使用类、id 和内联样式:
table select option,
table select option:hover,
table select option:focus,
table select option:active,
table select option:checked
{
background: linear-gradient(#fff,#fff); /* works */
color:red; /* does not work */
}
table select,
table select:focus,
table select:focus option,
table select:focus option:checked
{
color:red; /* does not work */
}
更新
问题似乎出在带有selected="selected" 的选项上。 Here's a fiddle.
【问题讨论】: