Last active
November 8, 2020 01:51
-
-
Save chkoar/5f22294e8f6bf29235f232a4904bca50 to your computer and use it in GitHub Desktop.
create crawiling/scrollable text in html ucing css only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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