.example1 h1 {
white-space: nowrap;
font-size: 3em;
color: limegreen;
position: relative;
width: 100%;
height: 100%;
margin: 0;
line-height: 50px;
text-align: left;
/* Starting position */
-moz-transform:translateX(-50%);
-webkit-transform:translateX(-50%);
transform:translateX(-50%);
/* Apply animation to this element */
-moz-animation: example1 15s linear infinite;
-webkit-animation: example1 15s linear infinite;
animation: example1 15s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes example1 {
0% { -moz-transform: translateX(-50%); }
100% { -moz-transform: translateX(-150%); }
}
@-webkit-keyframes example1 {
0% { -webkit-transform: translateX(-50%); }
100% { -webkit-transform: translateX(-150%); }
}
@keyframes example1 {
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%);
}
}
.example1 h2 {
white-space: nowrap;
font-size: 3em;
color: limegreen;
position: relative;
width: 100%;
height: 100%;
margin: 0;
line-height: 50px;
text-align: left;
/* Starting position */
-moz-transform:translateX(-50%);
-webkit-transform:translateX(-50%);
transform:translateX(-50%);
/* Apply animation to this element */
-moz-animation: example1 15s linear infinite;
-webkit-animation: example1 15s linear infinite;
animation: example1 15s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes example1 {
0% { -moz-transform: translateX(-50%); }
100% { -moz-transform: translateX(-150%); }
}
@-webkit-keyframes example1 {
0% { -webkit-transform: translateX(-50%); }
100% { -webkit-transform: translateX(-150%); }
}
@keyframes example1 {
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%);
}
}
<!DOCTYPE html>
<title>Example</title>
<!-- Styles -->
<style></style>
<!-- HTML -->
<div class="example1">
<h1>Scrolling text1...Scrolling text2...</h1><h2>Scrolling text3...Scrolling text4...Scrolling text5... </h2>
</div>
I'm using keyframe animation to create a scrolling text in CSS, I'm wondering how I could include two or more fonts (in this case h1, h2, h3...) in one line of no warp text.
I tried to duplicate the keyframe animation of h1 to h2, I understand I can achieve the one-line scrolling text of h1 and h2 by adjusting the keyframes but I feel there is a better way to make h2 follows h1 when scrolling.
Just change behavior default of h1, h2 to
display: inline-blockand move yourwhite-space: nowrapto .example1 which is your container.hope this will help you...