为什么无论我做什么都无法更改复选框颜色? [英] Why cannot change checkbox color whatever I do?

查看:22
本文介绍了为什么无论我做什么都无法更改复选框颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试设置复选框背景颜色的样式,但无论我做什么它都不会改变.我正在使用最新的 Firefox 29.

I try to style checkbox background color, but it won't change whatever I do. I am using firefox 29 latest.

css 中是否有一些规则更改或可能在浏览器中?

Is there some rule changes in css or may be in the browser?

CSS:

input[type="checkbox"] {
    background: #990000;    
}

.chk {
   background-color: #990000;  

}

这是一个演示 http://jsfiddle.net/6KXRg/

推荐答案

复选框无法设置样式.你需要一个第三方 js 插件,有很多可用的.

Checkboxes are not able to be styled. You would need a third party js plugin there are many available.

如果你想自己做这件事,它基本上涉及隐藏复选框,根据需要创建一个元素和样式,然后将其单击事件绑定到两个函数,一个用于更改其外观,另一个用于激活复选框的单击事件.

If you want to do this yourself it basically involves hiding the checkbox creating an element and styling that as you want then binding its click event to two functions one to change its look and another to activate the click event of the checkbox.

尝试为下拉选择元素上的小向下箭头设置样式时,也会出现同样的问题.

The same problem will arise when trying to style that little down arrow on a drop-down select element.

这篇关于为什么无论我做什么都无法更改复选框颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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