我需要更改复选框按钮的外观,确切地说,我需要放置自定义背景图片,而不是常规的灰色正方形。
现在我尝试了这样的事情:
[type="checkbox"] {
width: 15px;
height: 15px;
background-image: url("../images/checkbox.png")
}
[type="checkbox"]:checked {
width: 15px;
height: 15px;
-webkit-appearance: none;
background-image: url("../images/checkbox-c.png")
}
并且在选中时效果很好,但是在空闲时不会将背景图片更改为checkbox.png,而是保持简单的灰色正方形。
好吧,我不知道为什么其他答案被删除了,但这很可能在这里对我有用:
[type="checkbox"] {
width: 26px;
height: 26px;
-webkit-appearance: none; /*<----this needs to be added here.*/
background-image: url("https://cdn1.iconfinder.com/data/icons/windows8_icons_iconpharm/26/unchecked_checkbox.png")
}
[type="checkbox"]:checked {
width: 26px;
height: 26px;
-webkit-appearance: none;
background-image: url("https://cdn1.iconfinder.com/data/icons/windows8_icons_iconpharm/26/checked_checkbox.png")
}
<input type="checkbox" />
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句