Search code examples
csswordpressmarquee

Remove white space in CSS marquee


I am trying to add a marquee effect with CSS3 animation in Wordpress as it doesn't support the <marquee> tag. I would like to get rid of the white space in between each loop. I tried using nowrap but it doesn't work.

@keyframes marquee {
  0% {
    text-indent: 430px
  }
  100% {
    text-indent: -485px
  }
}

@-webkit-keyframes marquee {
  0% {
    text-indent: 430px
  }
  100% {
    text-indent: -485px
  }
}

.marquee {
  font-size: 50px;
  overflow: hidden;
  white-space: nowrap;
  animation: marquee 12s linear infinite;
  -webkit-animation: marquee 12s linear infinite;
}

.marquee:hover {
  -webkit-animation-play-state: paused;
  animation-play-state: paused;
}
<p class="marquee">
  <a href="#">
    SOON SOON SOON SOON SOON SOON SOON </a></p>

Link here: http://www.houseofbase.fr/preview/wordpress/comingsoon/


Solution

  • It is not a good idea to using text-indent for transform. Use this instead of your animation:

    @keyframes marquee {
    0% {
    transform: translateX(100vw);
     }
    100% {
        transform: translateX(-100vw);
       }
    }
    
    @-webkit-keyframes marquee {
      0% {
        transform: translateX(100vw);
      }
    100% {
        transform: translateX(-100vw);
      }
    }
    

    @keyframes marquee {
    0% {
    transform: translateX(100vw);
     }
    100% {
        transform: translateX(-100vw);
       }
    }
    
    @-webkit-keyframes marquee {
      0% {
        transform: translateX(100vw);
      }
    100% {
        transform: translateX(-100vw);
      }
    }
    .marquee {
      font-size: 50px;
      overflow: hidden;
      white-space: nowrap;
      animation: marquee 12s linear infinite;
      -webkit-animation: marquee 12s linear infinite;
    }
    
    .marquee:hover {
      -webkit-animation-play-state: paused;
      animation-play-state: paused;
    }
    <p class="marquee">
      <a href="#">
        SOON SOON SOON SOON SOON SOON SOON </a></p>