2
So I have a div
with 3 imagens
<div class="pai">
<img src="1.jpg" />
<img src="2.jpg" />
<img src="3.jpg" />
</div>
I would like these three images to run from right to left in order until you reach your positions, and when you arrive, stop there.
But I would like them not all to go out together. I would like the second to take a time of about 2 seconds after the exit of the first.
Thinking about it, I came up with the idea of using a foreach
. But you can implement this in css3
? as?
The model I made just makes them come in sequence.
Obs: NAY would like to use Javascript. I want to use CSS only.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sem título</title>
<style>
.pai {
width: 1000px;
height:300px;
position: relative;
overflow: hidden;
}
.pai > img {
width: 10%;
position:relative;
animation: animacao 5s;
animation-delay: 3s;
animation-direction: alternate;
}
@keyframes animacao{
0% {left: 110%; top: 0px;}
100% {left: 0px; top: 0px;}
}
</style>
</head>
<body>
<div class="pai">
<img src="1.jpg">
<img src="2.jpg">
<img src="3.jpg">
</div>
</body>
</html>
So that was it. But taking advantage, as it does for these figures, in their times of appearance, appear as if it were lightning (flash). But they only appear when, when you scroll down the page, you reach the div of them?
– Carlos Rocha
I believe it is now necessary JS, you will use?
– Thiago Santos
No, I just wanted to use CSS. It’s much faster and lighter css.
– Carlos Rocha
I believe that to capture the location of Scroll it is necessary to use JS, why can’t you use it? (explains better this idea of flash)
– Thiago Santos
kkk, it appears on the right with a clarity, when it arrives in the middle, it gives a flash in the image and then the image goes back to normal clarity state
– Carlos Rocha
I added an idea of flash, I apologize for using my photo, it was the first thing I had the hand haha
– Thiago Santos
I found an example of the type of flash I wanted: https://www.nubank.com.br/gerando-boletos/, night when going down (and only after arriving in the div), observe how the first image when scrolling the screen appears. It was this flash effect that I wanted. I think it has to do with the clarity of the image itself!
– Carlos Rocha
huh! your photo? Which of the 4? The 4? kkk
– Carlos Rocha
I changed the photo and put a generic of Google haha, I understood your need and I already update CSS! I repeat that to make the effect run only with the scrolling of the page you need Javascript.
– Thiago Santos
Yeah, I got it, I did it in pure JS. But then gave me another question, in that if, I should put all the elements that are below the screen height because the page has several Ivs one below the other, and the Ivs that are within the screen height? How will I predict this for the various screen sizes?
– Carlos Rocha
@Carlosrocha not really
$('#pai').offset().top
picks up how much scroll is needed to get to the div#pai
independent of screen size.– Thiago Santos
That is, the top of css, that is, the media from the beginning of the browser to the edge of the parent div
– Carlos Rocha