Why cannot change checkbox color whatever I do?

前端 未结 14 2256
孤城傲影
孤城傲影 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 09:06

    Styling the arrow & the checkbox colors.

    I haven't seen any answer deal with the arrow colors, so I thought I might add this for those wanting to also style the arrow inside the checkbox. I'm not suggesting to do these things, it's just for demo purposes.

    .checkbox-label {
        display: block;
        position: relative;
        margin: auto;
        cursor: pointer;
        font-size: 22px;
        line-height: 24px;
        height: 24px;
        width: 24px;
        clear: both;
    }
    
    .checkbox-label input {
        position: absolute;
        opacity: 0;
        cursor: pointer;
    }
    
    .checkbox-label .checkbox-custom {
        position: absolute;
        top: 0px;
        left: 0px;
        height: 24px;
        width: 24px;
        background-color: transparent;
        border-radius: 5px;
        transition: all 0.3s ease-out;
        -webkit-transition: all 0.3s ease-out;
        -moz-transition: all 0.3s ease-out;
        -ms-transition: all 0.3s ease-out;
        -o-transition: all 0.3s ease-out;
        border: 2px solid #000;
    }
    
    
    .checkbox-label input:checked ~ .checkbox-custom {
        background-color: #FFEA00;
        border-radius: 5px;
        -webkit-transform: rotate(0deg) scale(1);
        -ms-transform: rotate(0deg) scale(1);
        transform: rotate(0deg) scale(1);
        opacity:1;
        border: 2px solid #000;
    }
    
    .checkbox-label .checkbox-custom::after {
        position: absolute;
        content: "";
        left: 12px;
        top: 12px;
        height: 0px;
        width: 0px;
        border-radius: 5px;
        border: solid #000;
        border-width: 0 3px 3px 0;
        -webkit-transform: rotate(0deg) scale(0);
        -ms-transform: rotate(0deg) scale(0);
        transform: rotate(0deg) scale(0);
        opacity:1;
        transition: all 0.3s ease-out;
        -webkit-transition: all 0.3s ease-out;
        -moz-transition: all 0.3s ease-out;
        -ms-transition: all 0.3s ease-out;
        -o-transition: all 0.3s ease-out;
    }
    
    
    .checkbox-label input:checked ~ .checkbox-custom::after {
      -webkit-transform: rotate(45deg) scale(1);
      -ms-transform: rotate(45deg) scale(1);
      transform: rotate(45deg) scale(1);
      opacity:1;
      left: 8px;
      top: 3px;
      width: 6px;
      height: 12px;
      border: solid #000000;
      border-width: 0 2px 2px 0;
      background-color: transparent;
      border-radius: 0;
    }

提交回复
热议问题