I am trying to design a form without using JavaScript or JQuery. It includes a series of checkboxes. The idea is to display a certain gif after the checkbox if it is unchecked. Otherwise, display nothing after it. This is the code I have:
input[type=checkbox]::after
{
content: url(images/unchecked_after.gif);
position:relative;
left:15px;
z-index:100;
}
input[type=checkbox]:checked::after
{
content:"";
}
It works in Chrome but doesn't seem to be working in Firefox or IE. What is wrong?
input
is an element with an empty content model – and since::after
pseudo elements are rendered as child node of the element their are applied to, there’s a conflict. Some browsers allow to do it anyway – some don’t. Use the adjacent sibling combinator instead to format an element you put after the input element. w3.org/TR/2011/REC-css3-selectors-20110929/… – Eggcup