7
I have a CSS animation of an element that crosses the entire screen, from right to left, continuously infinitely:
#slider{
position: absolute;
top: 50px;
right: 0;
background: red;
width: 150px;
height: 50px;
animation: anima 3s linear infinite;
}
@keyframes anima{
from {right: 0}
to {right: 100%}
}
<div id="slider"></div>
Note that the element, disappearing from the screen on the left (right: 100%
), he returns to position right: 0
, that is, to the initial right-hand side and so on.
That’s not the effect I’d like. He wanted the element to be crossing the screen continuously, not returning to the initial position, and that when part of it left the screen, this part would already appear on the right side; and also not that it would start to appear again on the right side when it disappears all on the left, as does the nostalgic marquee
. That is, the element will always be visible, be it all or part of it.
It would be something like this, as illustrated in the image below as an example:
Is it possible to do this only with CSS? A solution with Javascript would also be valid, but I couldn’t think of a way to get to that result. You may have to clone the element, or use a pseudo-element ::before
or ::after
... Any idea?
A reference that will help you: https://stackoverflow.com/questions/40698758/css-infinite-horizontal-scroll-with-keyframe
– MarceloBoni
Now that I understood what you needed, I even found this other answer, but it’s pretty much the same as what I had given https://answall.com/questions/2960/barra-informa%C3%A7%C3%B5es-style-tv-similar-to-a-tag-Marquee/ I think only with CSS the only way would be with same pseudo element with two equal elements, because it can not be in two places at the same time.... Although for this example your in particular would give to do with SVG (I mean just a cube across the screen, if it is to be identical to the question, with SVG tb would give), but going before/after
– hugocsl
Face look that interesting, I know that SVG should not be the best option, but I know you like these stops, look how the animation in SVG looks softer! She’s not a clingy nanhuma, she’ll flow without "tremidinha"...
– hugocsl