Create a scrolling text on a webpage
You can create scrolling text using the <marquee>
tag or using CSS animations. Here’s a CSS-based solution (as <marquee>
is obsolete):
Example Code:
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title>Scrolling Text</title>
<style>
.scrolling-text {
white-space: nowrap;
overflow: hidden;
box-sizing: border-box;
animation: scroll 10s linear infinite;
}
@keyframes scroll {
0% { transform: translateX(100%); }
100% { transform: translateX(-100%); }
}
</style>
</head>
<body>
<div class=”scrolling-text”>
This is a scrolling text! Watch it move across the screen.
</div>
</body>
</html>