3
Not to cause confusion in the topic Div’s coming and going, I decided to create another because the problem has now changed.
I have the html:
* {
margin: 0 auto;
padding: 0;
}
body {
width: 900px;
}
.box {
position: relative;
width: 900px;
height: 250px;
top:0;
background-color: #fff;
}
.um, .dois, .tres {
position: absolute;
width: 250px;
height: 250px;
}
.um {
color: #fff;
animation: um 1s linear forwards;
-webkit-animation: um 1s linear forwards;
}
.dois {
color: #000;
animation: dois 2s linear forwards;
-webkit-animation: dois 2s linear forwards;
}
.tres {
color: #fff;
animation: tres 3s linear forwards;
-webkit-animation: tres 3s linear forwards;
}
@keyframes um {
0% { left: 100%; background-color: teal; }
50% { left: 150px; background-color: white;}
100% { left: 0%; background-color: crimson;}
}
@-webkit-keyframes um {
0% { left: 100%; background-color: teal; }
50% { left: 150px; background-color: white;}
100% { left: 0%; background-color: crimson;}
}
@keyframes dois {
0% { left: 100%; background-color: teal; }
50% { left: 450px; background-color: white;}
100% { left: 300px; background-color: crimson;}
}
@-webkit-keyframes dois {
0% { left: 100%; background-color: teal; }
50% { left: 450px; background-color: white;}
100% { left: 300px; background-color: crimson;}
}
@keyframes tres {
0% { left: 100%; background-color: teal; }
50% { left: 750px; background-color: white;}
100% { left: 600px; background-color: crimson;}
}
@-webkit-keyframes tres {
0% { left: 100%; background-color: teal; }
50% { left: 750px; background-color: white;}
100% { left: 600px; background-color: crimson;}
}
<div class="box">
<div class="um">1</div>
<div class="dois">2</div>
<div class="tres">3</div>
</div>
But I’m having trouble with effect logic. By my @keyframe, in 50% of the effects, the 3 div’s will meet. I would like the background color to change by 50% but the div’s should not meet, but their contents, at this moment, will be a mess.
The idea is the first div leaves the right running up to the left at its 0px position, then 1 second after the div two comes out and does the same until it reaches its 300px position and, analogously, the div 3 up to 600px.
Where am I going wrong?