Animation How to - Create Marquee with CSS3 animation








Question

We would like to know how to create Marquee with CSS3 animation.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src="http://leaverou.github.com/prefixfree/prefixfree.js"></script>
<style type='text/css'>
.marquee {<!--from  w w  w.  j  a va2  s .c  o m-->
  width: 450px;
  margin: 0 auto;
  overflow: hidden;
  white-space: nowrap;
  box-sizing: border-box;
  animation: marquee 3s linear infinite;
}

.marquee:hover {
  animation-play-state: paused
}

@keyframes marquee { 0% { text-indent: 100% }
              100%{text-indent: -50%}}
</style>
</head>
<body>
  <p class="marquee">Lorem ipsum dolor sit amet</p>
</body>
</html>

The code above is rendered as follows: