简体   繁体   English

无法在Chrome中的选择元素上使rgba()背景色正常工作

[英]Can't make rgba() background-colour on select element work in Chrome

Chrome Version 16.0.912.75 m running on Vista. Chrome在Vista上运行的16.0.912.75 m版。

I'm trying to apply an rgba background colour to a disabled select element, with the opacity at 0.2. 我正在尝试将rgba背景色应用于禁用的select元素,其不透明度为0.2。

It works fine in Firefox and Opera, but Chrome ignores the opacity, and just shows flat colour. 它可以在Firefox和Opera中正常工作,但Chrome会忽略不透明度,只显示纯色。 I've already tried adding -webkit-appearance: none. 我已经尝试添加-webkit-appearance:无。 This fixes the alpha value, but removes the button part fo the select element from view. 这将固定alpha值,但会从视图中删除select元素的按钮部分。

Does anyone know how how to have a background with an alpha value, and not hide the button part of select? 有谁知道如何使用alpha值作为背景,而不隐藏select的按钮部分?

http://jsfiddle.net/EMSmZ/9/ <== I've edited this to confirm that rgba is otherwise working for background colour, but not for select. http://jsfiddle.net/EMSmZ/9/ <==我已经对此进行了编辑,以确认rgba可以用于背景颜色,但不能用于选择。 The two boxes have different background transparencies in Chrome, but the selects don't. 这两个框在Chrome中具有不同的背景透明胶片,但是所选内容却没有。


Still nothing, submitted a bug report: http://code.google.com/p/chromium/issues/detail?id=110437 仍然没有,提交了一个错误报告: http : //code.google.com/p/chromium/issues/detail?id=110437

I hate to break this to you, but styling form elements with CSS is just a bag of hurt. 我不愿意向您透露此信息,但是使用CSS设置表单元素的样式只是一袋痛。 There's a reason everyone uses Javascript replacement techniques to change the look and feel of form elements.. (except text and text area essentially) 每个人都有理由使用Javascript替换技术来更改表单元素的外观和感觉。(基本上是文本和文本区域除外)

I ran into the same problem developing a form for a client. 我遇到了为客户开发表单的相同问题。 The workaround I ended up using was to set the background-color to a lighter version ( #faebe7 ) of whatever base I color I wanted to use, in this case red, rather than using rgba(255,0,0,0.4) . 我最终使用的解决方法是将background-color设置为较浅的版本( #faebe7 ),该颜色是我想使用的任何基础颜色(在这种情况下为红色),而不是使用rgba(255,0,0,0.4)

not working as is in chrome 16.0.912.75 m on XP. 在XP上无法像Chrome 16.0.912.75 m那样工作。 IF you give the disabled 'opacity:.2; 如果给禁用的'opacity:.2; it changes the opacity of the whole element. 它改变了整个元素的不透明度。 Not sure what effect you are trying to achieve, maybe show some context to help offer a solution. 不确定要达到的效果,可能会显示一些上下文来提供解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM