I have programmed a continuous horizontal text scroll using CSS @keyframes
and two identical div
tags.
The issue I am facing is when the loop starts again, there is a small, but noticeable, pause before the text scrolls again. I would like the scroll to be continuous with no pause, even whether that means to not use CSS @keyframes
and instead javascript/jQuery.
My code is below.
@keyframes infiniteScroll {
from {
transform: translateX(0)
}
to {
transform: translateX(calc(0px - 50%));
}
}
#scrolling-header-parent-container {
width: 100%;
background-color: black;
overflow-x: hidden;
#scrolling-header-container {
display: flex;
width: fit-content;
height: 8vh;
font-size: 30px;
align-items: center;
overflow-x: hidden;
animation-name: infiniteScroll;
animation-duration: 20s;
animation-iteration-count: infinite;
animation-timing-function: linear;
.scrolling-header-container-item {
white-space: nowrap;
color: white;
}
}
}
<div id="scrolling-header-parent-container">
<div id="scrolling-header-container">
<div class="scrolling-header-container-item">
AUTHENTIC VIETNAMESE FOOD • INDIAN CUISINE • CHURROS & COFFEE • BUBBLE TEA • ESCAPE ROOM EXPERIENCE • SOUFFLE PANCAKE & DESSERT CAFE • COCKTAIL BAR • TAIWANESE FRIED CHICKEN • CHINESE HOTPOT • POLISH STREET FOOD • KOREAN BBQ •
</div>
<div class="scrolling-header-container-item">
AUTHENTIC VIETNAMESE FOOD • INDIAN CUISINE • CHURROS & COFFEE • BUBBLE TEA • ESCAPE ROOM EXPERIENCE • SOUFFLE PANCAKE & DESSERT CAFE • COCKTAIL BAR • TAIWANESE FRIED CHICKEN • CHINESE HOTPOT • POLISH STREET FOOD • KOREAN BBQ •
</div>
</div>
</div>
2
Answers
You need to use JavaScript. Change timeInMiliSeconds to change speed.