Skip to content

Instantly share code, notes, and snippets.

@chkoar
Last active November 8, 2020 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chkoar/5f22294e8f6bf29235f232a4904bca50 to your computer and use it in GitHub Desktop.
Save chkoar/5f22294e8f6bf29235f232a4904bca50 to your computer and use it in GitHub Desktop.
create crawiling/scrollable text in html ucing css only
<!DOCTYPE html>
<title>Example</title>
<!-- Styles -->
<style>
.crawling {
height: 50px;
overflow: hidden;
position: relative;
}
.crawling h3 {
font-size: 3em;
color: limegreen;
position: absolute;
width: 100%;
height: 100%;
margin: 0;
line-height: 50px;
text-align: center;
/* Starting position */
-moz-transform:translateX(100%);
-webkit-transform:translateX(100%);
transform:translateX(100%);
/* Apply animation to this element */
-moz-animation: crawling 20s linear infinite;
-webkit-animation: crawling 20s linear infinite;
animation: crawling 20s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes crawling {
0% { -moz-transform: translateX(100%); }
100% { -moz-transform: translateX(-100%); }
}
@-webkit-keyframes crawling {
0% { -webkit-transform: translateX(100%); }
100% { -webkit-transform: translateX(-100%); }
}
@keyframes crawling {
0% {
-moz-transform: translateX(100%); /* Firefox bug fix */
-webkit-transform: translateX(100%); /* Firefox bug fix */
transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%); /* Firefox bug fix */
-webkit-transform: translateX(-100%); /* Firefox bug fix */
transform: translateX(-100%);
}
}
</style>
<!-- HTML -->
<div class="crawling">
<h3>Scrolling text... </h3>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment