Why cannot change checkbox color whatever I do?

前端 未结 14 2231
孤城傲影
孤城傲影 2020-11-28 08:54

I try to style checkbox background color, but it won\'t change whatever I do. I am using firefox 29 latest.

Is there some rule changes in css or may be in the browse

14条回答
  •  孤城傲影
    2020-11-28 08:59

    you cant change the background of checkbox but some how you can do a trick try this :)

    .divBox {
        width: 20px;
        height: 20px;
        background: #ffffd;
        margin: 20px 90px;
        position: relative;
        -webkit-box-shadow: 0px 1px 3px rgba(0,0,0,0.5);
        -moz-box-shadow: 0px 1px 3px rgba(0,0,0,0.5);
        box-shadow: 0px 1px 3px rgba(0,0,0,0.5);
    }
    
    .divBox label {
        display: block;
        width: 20px;
        height: 20px;
        -webkit-transition: all .5s ease;
        -moz-transition: all .5s ease;
        -o-transition: all .5s ease;
        -ms-transition: all .5s ease;
        transition: all .5s ease;
        cursor: pointer;
        position: absolute;
        top: 1px;
        z-index: 1;
        /* 
        use this background transparent to check the value of checkbox 
        background: transparent;
        */
        background: Black;
        -webkit-box-shadow:inset 0px 1px 3px rgba(0,0,0,0.5);
        -moz-box-shadow:inset 0px 1px 3px rgba(0,0,0,0.5);
        box-shadow:inset 0px 1px 3px rgba(0,0,0,0.5);
    }
    
    .divBox input[type=checkbox]:checked + label {
        background: green;
    }

提交回复
热议问题