Make checkbox in chrome look like one in IE

前端 未结 4 1237
长情又很酷
长情又很酷 2021-01-15 02:05

The checkbox in IE and chrome looks different.

Chrome

\"enter

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-15 02:45

    IE and Google Chrome works on different rendering engines (Layout engine ). webkit-box-shadow works in google chrome and latest Safari which uses webkit layout engine.

    .squaredFour {
      width: 18px;
      position: relative;
      margin: 18px auto;
    }
    .squaredFour label {
      width: 18px;
      height: 18px;
      cursor: pointer;
      position: absolute;
      top: 0;
      left: 0;
      background: #fcfff4;
      background: -webkit-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
      background: linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
      border-radius: 4px;
      box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0, 0, 0, 0.5);
    }
    .squaredFour label:after {
      content: '';
      width: 8px;
      height: 4px;
      position: absolute;
      top: 4px;
      left: 4px;
      border: 3px solid #333;
      border-top: none;
      border-right: none;
      background: transparent;
      opacity: 0;
      -webkit-transform: rotate(-45deg);
          -ms-transform: rotate(-45deg);
              transform: rotate(-45deg);
    }
    .squaredFour label:hover::after {
      opacity: 0.5;
    }
    .squaredFour input[type=checkbox] {
      visibility: hidden;
    }
    .squaredFour input[type=checkbox]:checked + label:after {
      opacity: 1;
    }
    
    
    
    

    http://jsbin.com/saxunaqiqi/1/edit

    This will work in Google Chrome and IE 10+ browsers.

提交回复
热议问题