2

pseudo elements :after, :before not working in Firefox, but work perfectly in Chrome.

Can anyone explain how to fix it and why this occur:

Here is jsfiddle

HTML:

 <input type="checkbox" class="checkbox" checked>

CSS:

 .checkbox {
  position: relative;
  top: -0.375rem;
  margin: 0 1rem 0 0;
  left: 5px;
  cursor: pointer;
  display: inline-block;
  height: 9px;
  z-index: 0;
}

.checkbox::before {
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  content: "";
  position: absolute;
  left: 0;
  z-index: 2;
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid #CCCCCC;
}

.checkbox:checked::before {
    border: 3px solid #CCCCCC;
  -webkit-transform: rotate(-45deg);
  -moz-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  transform: rotate(-45deg);
  height: 0.9rem;

  border-color: #8ECA24;
  border-top-style: none;
  border-right-style: none;
}

.checkbox::after {
  content: "";
  position: absolute;
  top: -0.125rem;
  left: 0;
  width: 1.1rem;
  height: 1.1rem;
  background: #fff;
  cursor: pointer;
}
G.L.P
  • 7,119
  • 5
  • 25
  • 41
mondayguy
  • 973
  • 2
  • 12
  • 34
  • Looking at the linked question, I think Chrome may be doing something it shouldn't be in this instance. Firefox would appear to be working correctly by not outputting the pseudo element. – Hidden Hobbes Oct 27 '15 at 08:57
  • 1
    `:after` and `:before` are not supported on **form elements (inputs)** and **image elements**. – om_jaipur Oct 27 '15 at 09:09

0 Answers0