Make checkbox in chrome look like one in IE

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

The checkbox in IE and chrome looks different.

Chrome

\"enter

相关标签:
4条回答
  • 2021-01-15 02:23

    Does this fit your needs? http://codepen.io/anon/pen/dovdWv

    Basically, I used -webkit-appearance: inherit; to reset the checkbox to initial state, and used the :after pseudo-element to create your check mark.

    Tested only on Chrome.

    0 讨论(0)
  • 2021-01-15 02:25

    A really simple way is just to add -webkit-appearance: none;. But you will need to then style the checkbox to match what you want. Here is an example:

    http://jsfiddle.net/tzdcbyc5/

    <input class="checkbox" type="checkbox">
    <input class="checkbox" type="checkbox" checked>
    
    .checkbox {
        position: relative;
        width: 14px;
        height: 14px;
        border: 1px solid #111;
        background: #fff;
        -webkit-appearance: none;
        appearance: none;
    }
    
    .checkbox:checked {
        background: url(http://vignette3.wikia.nocookie.net/roblox/images/5/57/Very-Basic-Checkmark-icon.png/revision/latest?cb=20131125154354) no-repeat center center;
        background-size: 100%;
    }
    
    0 讨论(0)
  • 2021-01-15 02:44

    You can use "filter: brightness" which doesn't work in IE so it doesn't affect IE but can make the chrome checkbox and radio buttons look almost white with something like this:

    input[type="checkbox"],
    input[type="radio"] {
        filter: brightness(1.2);
    }
    
    /* Set disabled back to grey */
    input[type="checkbox"]:disabled,
    input[type="radio"]:disabled {
        filter: brightness(0.9);
    }
    
    0 讨论(0)
  • 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;
    }
    
    
    
    <section title=".squaredFour">
        <div class="squaredFour">
          <input type="checkbox" value="None" id="squaredFour" name="check" checked />
          <label for="squaredFour"></label>
        </div>
     </section>
    

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

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

    0 讨论(0)
提交回复
热议问题