I'm having some issues getting my CSS checkbox to show up on Firefox. I'm using an :after: element to style the new checkbox, and it works fine on webkit browsers (Chrome and Safari) but isn't visible on Firefox. I've got it so that the native checkbox is visible if the styled one isn't so it's not terrible, but I'd like to have a consistent experience.
It seems as though the :after element is just not being rendered in FF when I inspect the code.
Here's my HTML:
<div class="text-center checkbox">
<label>
<input type="checkbox" value="on">
</label>
</div>
The CSS:
.checkbox {
label {
position: relative;
cursor: pointer;
padding-left: 1em;
}
&:hover {
input[type=checkbox] {
&:after {
cursor: pointer;
border-color: blue;
}
}
}
input[type=checkbox] {
position: absolute;
&:after {
background: white;
content: "";
display: inline-block;
width: 1.5em;
height: 1.5em;
position: relative;
top: -4px;
border-radius: 3px;
border: 2px solid gray;
transition: border 0.3s ease;
}
&:checked {
&:after {
background-image: url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNDkgNDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgaWQ9IlBhZ2UtMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PHBvbHlsaW5lIGlkPSJQYXRoIiBzdHJva2U9IiM0MjkxREIiIHN0cm9rZS13aWR0aD0iMTEiIHBvaW50cz0iMy43NTY1MzE0OCAxOC45ODA0MDUyIDIyLjc1Mzc0MjQgMzMuMDg5OTk4NiA0NC41ODgzMTcxIDMuNDk1NDY5MjIiPjwvcG9seWxpbmU+PC9nPjwvc3ZnPg==);
background-repeat: no-repeat;
background-position: center left 2px;
background-size: 75%;
border-color: blue;
}
}
}
}
I have it set up on a Codepen. In my CSS file, I've noted where I forked this code from and modified; given the markup we're using I had to make some tweaks to the elements being styled. The inspiration code works cross browser which is further mystifying me!