在 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>
有人知道修复吗?
this html only in chrome makes the selected value non visible, the bacground of the select in other browsers is colored, only in chrome it's white
<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>
anybody knows a fix ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Google Chrome 不支持选择上的背景图像,这就是样式表中的规则被破坏的原因。
要修复它,您需要分别指定背景颜色和背景图像,以便不支持背景图像的浏览器不会忽略整个规则,但至少会选择它们支持的规则:
或者,您可以只在 style 属性中设置背景颜色,但这并不像其他解决方案那么干净:
Google Chrome doesn't support a background image on a select, which is why the rule in the stylesheet breaks.
To fix it you will need to specifiy the background color and background image separately, so that browsers that don't support the background image will not ignore the entire rule but will at least pick up the rules they do support:
Alternately, you could just set the background color in the style attribute, but this is not as clean as the other solution:
我知道这有点旧,但我在寻找相同的 anwser 时遇到了它,这是修复此
@media screen 的 Css 方法和 (-webkit-min-device-pixel-ratio:0) { // target仅-webkit浏览器
}
希望有帮助
I know this is a little old but I ran onto it when looking for the the same anwser and the is a Css way to fix this
@media screen and (-webkit-min-device-pixel-ratio:0) { // target only -webkit browsers
}
Hope that it helps
首先你必须检测浏览器来解决问题:
然后将字体颜色更改为黑色:
First you have to detect the browser to fix the issue:
Then change the font color to black:
使用 jQuery,您可以
在 http://jsfiddle.net/B2NFE/2/ 处检查工作示例
With jQuery you can do this
Check working example at http://jsfiddle.net/B2NFE/2/