简体   繁体   English

复选框css样式看起来像禁用

[英]Checkbox css style to look like disabled

I need to style enabled checkbox to look like disabled, but style="background: #e4e4ee4;" 我需要启用样式复选框看起来像禁用,但style="background: #e4e4ee4;" doesn't work. 不起作用。 Could someone help me? 有人能帮助我吗? How to make checkbox to look like it has attribute disabled with css? 如何使复选框看起来像已使用css禁用属性? (Case with usage attribute disable is forbidden). (禁止使用属性禁用的情况)。

You could set opacity instead of background. 您可以设置不透明度而不是背景。

Simple Example: https://jsfiddle.net/gfb0gc3h/2/ 简单示例: https//jsfiddle.net/gfb0gc3h/2/

<input type="checkbox" class="mycheckbox"/>

.mycheckbox
{
  opacity:0.5;
}

As adopted from Nezure's answer, but don't forget to add the pointer-events property and set it to none to prevent clicks! 从Nezure的回答中采用,但不要忘记添加pointer-events属性并将其设置为none以防止点击!

.disabled-checkbox {
  opacity:0.5;
  pointer-events: none;
}

Example: https://jsfiddle.net/gfb0gc3h/67/ 示例: https//jsfiddle.net/gfb0gc3h/67/

我的意思是你可以在HTML代码中禁用它.....你正在尝试做什么?

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

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