加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – 自定义CSS3复选框在Firefox或IE上不起作用

发布时间:2020-12-14 23:44:24 所属栏目:资源 来源:网络整理
导读:小提琴: http://jsfiddle.net/V98W8/ 我有一个自定义复选框,在Chrome中看起来很完美,但在Firefox或IE浏览器中显示完全破坏了. 我已经尝试添加自定义前缀和一切,但它似乎没有解决问题. #milestone-table input[type="checkbox"] { -webkit-appearance: none;
小提琴: http://jsfiddle.net/V98W8/

我有一个自定义复选框,在Chrome中看起来很完美,但在Firefox或IE浏览器中显示完全破坏了.

我已经尝试添加自定义前缀和一切,但它似乎没有解决问题.

#milestone-table input[type="checkbox"] {
    -webkit-appearance: none;
      -moz-appearance: none;
    appearance: none;
    background-color: #fafafa;
    border: 1px solid lightgrey;
    border-radius: 26px;

    -webkit-box-shadow: inset 0 0 0 1px lightgrey;
    box-shadow: inset 0 0 0 1px lightgrey;
    cursor: pointer;
    height: 28px;
    position: relative;

    -webkit-transition: border .25s .15s,box-shadow .25s .3s,padding .25s;
    -moz-transition: border .25s .15s,padding .25s;
    -o-transition: border .25s .15s,padding .25s;
    -ms-transition: border .25s .15s,padding .25s;
    transition: border .25s .15s,padding .25s;
    width: 54px;
    vertical-align: top;
    outline: none;
}

#milestone-table .controls input[type="checkbox"] {
    margin-top: 10px;
}

#add-milestone {
    position: relative;
    top: 7px;
    left: 90%;
}

#milestone-table {
    margin-top: -20px;
}

#milestone-table input[type="checkbox"]:after {
    background-color: white;
    border: 1px solid lightgrey;
    border-radius: 24px;

    -webkit-box-shadow: inset 0 -3px 3px rgba(0,0.025),0 1px 4px rgba(0,0.15),0 4px 4px rgba(0,0.1);
    box-shadow: inset 0 -3px 3px rgba(0,0.1);
    content: '';
    display: block;
    height: 24px;
    left: 0;
    position: absolute;
    right: 26px;
    top: 0;

    -webkit-transition: border .25s .15s,left .25s .1s,right .15s .175s;
    -moz-transition: border .25s .15s,right .15s .175s;
    -o-transition: border .25s .15s,right .15s .175s;
    -ms-transition: border .25s .15s,right .15s .175s;
    transition: border .25s .15s,right .15s .175s;
}

#milestone-table input[type="checkbox"]:checked {
    border-color: #53d76a;

    -webkit-box-shadow: inset 0 0 0 13px #53d76a;
    box-shadow: inset 0 0 0 13px #53d76a;
    padding-left: 18px;

    -webkit-transition: border .25s,box-shadow .25s,padding .25s .15s;
    -moz-transition: border .25s,padding .25s .15s;
    -o-transition: border .25s,padding .25s .15s;
    -ms-transition: border .25s,padding .25s .15s;
    transition: border .25s,padding .25s .15s;
}

#milestone-table input[type="checkbox"]:checked:after {
    border-color: #53d76a;
    left: 26px;
    right: 0;

    -webkit-transition: border .25s,left .15s .25s,right .25s .175s;
    -moz-transition: border .25s,right .25s .175s;
    -o-transition: border .25s,right .25s .175s;
    -ms-transition: border .25s,right .25s .175s;
    transition: border .25s,right .25s .175s;
}

解决方法

可悲的是,据我所知,这是Firefox中的一个老版本,尚未修复.如果它们最近没有改变(从你的问题来看,它们没有改变),无论你做什么,样式复选框和单选按钮在Firefox中都无法正常工作.

通常,解决此问题的常用方法是简单地使用常规div并让它们通过javascript或类似方法切换隐藏字段.绝对不是一个漂亮的解决方案,但在他们修复这个bug之前,你无能为力.

我制作了a quick example,它使用了一个隐藏的复选框,标签实现了至少有效的功能.当然,它不仅仅是使用常规输入标签,但它应该在Firefox中工作(我猜IE,但我还没有测试).

<div id="milestone-table">
    <p>Checkbox</p>
    <label>
        <input type="checkbox"/>
        <label class="checkbox"/>
    </label>
</div>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读