html - 启用时更改复选框颜色

标签 html asp.net css

我有以下复选框,当复选框是 检查 V 的颜色为绿色,我应该怎么做?

<input type="checkbox" checked="checked" disabled="disabled"  />

这是行不通的

<style type="text/css">
    input[type=checkbox], input[type=file] {
        display: inline-block;
        margin-right: 15px;
    }
    input[type="checkbox"]:disabled:checked + label::after {
        border: 3px solid #228B22;
        border-top: none;
        border-right: none;
    }


    input[type="checkbox"]:checked + label::after {
        content: '';
        position: absolute;
        width: 1.2ex;
        height: 0.4ex;
        background: rgba(0, 0, 0, 0);
        top: 0.9ex;
        left: 0.4ex;
        border: 3px solid #1062a4;
        border-top: none;
        border-right: none;
        -webkit-transform: rotate(-45deg);
        -moz-transform: rotate(-45deg);
        -o-transform: rotate(-45deg);
        -ms-transform: rotate(-45deg);
        transform: rotate(-45deg);
    }
</style>

最佳答案

更新*

我编辑了 FIDDLE,这是你需要的(enable = green and disable for the heck of it):

input[type="checkbox"]:disabled:checked + label::after {
    border: 3px solid #228B22;
    border-top: none;
    border-right: none;
}


input[type="checkbox"]:checked + label::after {
   content: '';
   position: absolute;
   width: 1.2ex;
   height: 0.4ex;
   background: rgba(0, 0, 0, 0);
   top: 0.9ex;
   left: 0.4ex;
   border: 3px solid #1062a4;
   border-top: none;
   border-right: none;
   -webkit-transform: rotate(-45deg);
   -moz-transform: rotate(-45deg);
   -o-transform: rotate(-45deg);
   -ms-transform: rotate(-45deg);
   transform: rotate(-45deg);
}

FIDDLE

关于html - 启用时更改复选框颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23547170/

相关文章:

javascript - 使用 Javascript 显示对话框

php - 网页刷新,mysql更新

c# - 在 GridView 中,我的 Roe 未更新或删除

asp.net - 自动转义 Asp.Net MVC

c# - 编辑时禁用用户名验证

css - 如何使用表单生成器格式化模态

jquery - SmoothScroll 不适用于表格导航

html - 通过URL生成的托管图像(特别是QR码)

html - 以编程方式启动 html5 datetime-local

html - 如何将文本叠加到容器内的 flexbox 图像上并使其响应