CSS pseudo selectors ::before and ::after will not displayed in FF 44 and IE11

断了今生、忘了曾经 提交于 2019-12-11 12:47:29

问题


To style inputs of type "checkbox" and "radio" if they are mandatory I created some css information:

input[type=checkbox].is-mandatory::before {
    position: absolute;
    left: -5px;
    top: -5px;
    border: solid 1px #A94442;
	border-radius: 4px;
    width: 22px;
    height: 22px;
    content: "";
}

input[type=checkbox].is-mandatory::after {
    position: absolute;
    left: -4px;
    top: -4px;
    border: solid 4px #F2DEDE;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    content: "";
}
<div class="checkbox">
    <label>
        <input class="is-mandatory" type="checkbox" id="chk0" name="chk0" value="0">
        A simple checkbox (mandatory)
    </label>
</div>

<div class="radio">
    <label>
        <input class="is-mandatory" type="radio" id="chk1" name="chk1" value="1">
        A radio (mandatory)
    </label>
</div>

Unfortunately it seems only displayed in Chrome and not in FF44 and IE11

styled checkbox and radio in chrome

Is there someting missing in css declaration to get the same view in IE and FF like in Chrome?


回答1:


Keep in mind that while an input can't have a :before and :after pseudo-element, the LABEL can. Set your label to have a "for" attribute that's equal to the name/id of your input, and it might help solve some issues.




回答2:


Sorry but Pseudo elements doesn't support on input. Please check the link below but i am not pretty sure that this is gonna help you

http://arthurgouveia.com/prettyCheckable/



来源:https://stackoverflow.com/questions/35937873/css-pseudo-selectors-before-and-after-will-not-displayed-in-ff-44-and-ie11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!