在 Chrome 中查看时选择框中的白色背景

Omu*_*Omu 5 html css jquery select google-chrome

此 html 仅在 chrome 中使所选值不可见,在其他浏览器中选择的背景是彩色的,只有在 chrome 中它是白色的

<HTML>
<head>
    <title>
        title
    </title>    
    <link id="siteThemeLink" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/themes/excite-bike/jquery-ui.css"
        rel="stylesheet" type="text/css" />          
</head>

<body>
<select class='ui-state-error'>
    <option>hi</option>
    <option>hi</option>
    <option>hi</option>
</select>
</body>
</HTML>
Run Code Online (Sandbox Code Playgroud)

有人知道修复吗?

Hus*_*ein -5

使用 jQuery 你可以做到这一点

$('#selectbox').css({
    'background': 'blue'
});
Run Code Online (Sandbox Code Playgroud)

检查工作示例http://jsfiddle.net/B2NFE/2/

  • 天哪,你为什么要使用 javascript(更糟糕的是,使用整个 javascript 库)来修复一个小的 css 问题?如果你的轮胎漏气了,你会买一辆巨型卡车来运载你的车“这样它仍然可以行驶”,还是只是修理漏气的轮胎? (4认同)
  • 刚刚测试了这个例子,它在 Chrome 中不起作用!单击下拉菜单时,背景颜色为白色。这意味着您无法在没有猜测的情况下选择选项。请我们将此不被接受的答案作为答案! (2认同)