My Development Notes


How to create moving text animation from right to left using CSS animation


Here’s how you can create a moving text animation using HTML and CSS using @keyframes keyword :

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Moving Text Panel Animation</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="text-panel">
      <p>
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. Facere omnis
        voluptatum quam numquam recusandae dolorum unde voluptates saepe!
        Laudantium ab fugiat, eos omnis modi, tempora magni tenetur dolores
      </p>
    </div>
  </body>
</html>
body {
  margin: 0;
  overflow: hidden;
}

.text-panel {
  background-color: antiquewhite;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

p {
  font-size: 25px;
}

.text-panel p {
  display: inline-block;
  animation: runningText 15s linear infinite;
}

@keyframes runningText {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *