Search code examples
cssfirefoxcss-transitionscss-transforms

CSS transform rotate pixel issue in firefox


I'm trying to create swing button with transform rotate property , It's works fine in opera and chrome browsers but in firefox its create weird pixel issue in the border of the button:

Button rendering in Firefox

My css code for button & swing keyframes

.RedButton {
  background-color: #bc0000;
  border-radius: 7px;
  border: 1px solid #bc0000;
  display: inline-block;
  cursor: pointer;
  color: #fff !important;
  font-family: Arial;
  font-size: 30px;
  font-weight: bold;
  padding: 7px 24px;
  text-decoration: none;
  margin-top: 15px;
  animation: swing 5s infinite;
  -moz-animation: swing 5s infinite;
  transition: 0.2s;
  -moz-transition: 0.2s;
}

@-moz-keyframes swing {
  20%,
  60% {
    -moz-transform: rotate(5deg);
  }
  40%,
  80% {
    -moz-transform: rotate(-5deg);
  }

  100% {
    -moz-transform: rotate(0deg);
  }
}

@keyframes swing {
  20%,
  60% {
    transform: rotate(5deg);
  }
  40%,
  80% {
    transform: rotate(-5deg);
  }
  100% {
    transform: rotate(0deg);
  }
}
<div class="RedButton">Get Started Now!</div>

Am i missing something ?


Solution

  • adding a tiny shadow make it look better:

    .RedButton {
      background-color: #bc0000;
      border-radius: 7px;
      border: 1px solid #bc0000;
      display: inline-block;
      cursor: pointer;
      color: #fff ;
      font-family: Arial;
      font-size: 30px;
      font-weight: bold;
      padding: 7px 24px;
      text-decoration: none;
      margin-top: 15px;
      animation: swing 5s infinite;
      box-shadow: 0 0 1px #bc0000;
    }
    
    
    @keyframes swing {
      20%,
      60% {
        transform: rotate(5deg);
      }
      40%,
      80% {
        transform: rotate(-5deg);
      }
    }
    <div class="RedButton">Get Started Now!</div>