复选框不显示

时间:2019-02-26 11:07:59

标签: css asp.net-mvc-4 twitter-bootstrap-3

我有一个复选框在MS Edge中无法正确显示。我尝试使用元标记。

我的复选框在Edge中如下所示:

enter image description here

并在Chrome和Mozzila中这样:

enter image description here

毕竟我真的不知道该怎么办。

HTML(Razor):

@Html.CheckBoxFor(model => model.IsPublic, new { @class = "flipswitch" })

我的CSS:

    .flipswitch {
    position: relative;
    background: white;
    width: 120px;
    height: 40px;
    -webkit-appearance: initial;
    border-radius: 3px;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    outline: none;
    font-size: 14px;
    font-family: Trebuchet, Arial, sans-serif;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid #ddd;
}

    .flipswitch:after {
        position: absolute;
        top: 5%;
        display: block;
        line-height: 32px;
        width: 45%;
        height: 90%;
        background: #b11217;
        box-sizing: border-box;
        text-align: center;
        transition: all 0.3s ease-in 0s;
        color: white;
        border: #888 1px solid;
        border-radius: 3px;
    }

    .flipswitch:after {
        left: 2%;
        content: "OFF";
    }

    .flipswitch:checked:after {
        left: 53%;
        content: "ON";
    }

1 个答案:

答案 0 :(得分:0)

您可以尝试将'display:block'添加到'.flipswitch'类吗?

我的意思是:

.flipswitch {
    display: block;
    position: relative;
    background: white;
    width: 120px;
    height: 40px;
    -webkit-appearance: initial;
    border-radius: 3px;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    outline: none;
    font-size: 14px;
    font-family: Trebuchet, Arial, sans-serif;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid #ddd;
}