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

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

问题描述

我尝试设置复选框背景颜色的样式,但是它不会改变我所做的任何事情.我正在使用最新的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.

如果您想自己执行此操作,则基本上涉及隐藏复选框以创建元素并对其进行样式设置,然后将其click事件绑定到两个函数,一个用于更改其外观,另一个用于激活复选框的click事件.

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天全站免登陆