css checkbox 改选中颜色

     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: #319950;
        border-color: #319950;
        background-color: #319950;
    }

    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;
    }
posted @ 2022-09-06 17:28  隰荷华  阅读(1115)  评论(0编辑  收藏  举报