Firefox - Remove border from undecorated checkbox

前端 未结 2 1190
清歌不尽
清歌不尽 2021-01-15 23:14

I have a checkbox the has the appearance: none;. This working in chrome, but in Firefox it leaves behind an inset border that I cannot remove. I have tried

2条回答
  •  隐瞒了意图╮
    2021-01-16 00:08

    Unfortunately, it doesn't seem that setting any properties on the checkbox will help.

    The only simple workaround that I have found is to wrap the checkbox in a

    , and obscure the borders.

    See my Fiddle.

    HTML:

    CSS:

    input[type="checkbox"] {
        width: 110px;
        height: 110px;
        background: red;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border: none;
        position: relative;
        left: -5px;
        top: -5px;
    }
    .checkbox-container {
        position: absolute;
        display: inline-block;
        margin: 20px;
        width: 100px;
        height: 100px;
        overflow: hidden;
    }
    

    By the way, (in Firefox at least), setting background doesn't have any effect.

提交回复
热议问题