I am currently working on a CSS effect for some images. My goal is to have an image appear from the left side, move towards the right side, then reappear from the left and repeat this cycle. I managed to achieve this using the code below:
@keyframes slideAnimation {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(100%);
}
}
.row-1 {
overflow: hidden;
display: flex;
flex-direction: column;
align-items: flex-start;
width: 100%;
height: 100%;
}
.image-container {
position: absolute;
top: 4%;
width: 100vw !important;
overflow: hidden;
animation: slideAnimation 18s linear infinite;
}
<div class="row-1">
<div class="image-container">
<img class="img" src="/src/assets/image.svg" alt="img">
</div>
</div>
While this works fine for desktop screens, it causes scrolling issues on mobile devices. Even though the image properly loops back from the left after reaching the right side, the container's width of 100vw creates unwanted horizontal scrollbars. This affects other positioned elements on my page as well. Is there a way to disable this scroll or achieve the same effect in a different manner without impacting other elements on the page?