checkbox复选框自定义背景颜色和选中样式

效果图如下:

 

 

 

复制代码
/* css 复选框 */
    input[type=checkbox] {
        cursor: pointer;
        position: relative;
    }

    input[type=checkbox]::after {
        position: absolute;
        top: 0;
        background-color: #fff;
        color: #fff;
        width: 14px;
        height: 14px;
        display: inline-block;
        visibility: visible;
        padding-left: 0px;
        text-align: center;
        content: ' ';
        border-radius: 2px;
        box-sizing: border-box;
        border: 1px solid #ddd;
    }

    input[type=checkbox]:checked::after {
        content: "";
        background-color: #037DF3;
        border-color: #037DF3;
        background-color: #037DF3;
    }

    input[type=checkbox]:checked::before {
        content: '';
        position: absolute;
        top: 1px;
        left: 5px;
        width: 3px;
        height: 8px;
        border: solid white;
        border-width: 0 2px 2px 0;
        transform: rotate(45deg);
        z-index: 1;
    }
复制代码
<!-- html -->
<input type="checkbox">

 

posted @   蛙仔  阅读(9834)  评论(0编辑  收藏  举报
编辑推荐:
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
阅读排行:
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示