For a while now, I've been utilizing the code below (or something similar) to showcase information on specific posts:
Html:
<div class="main">
<div class="info">
<div>Words</div>
<div>Words</div>
<div>Words</div>
<div>Words</div>
<div>Words</div>
</div>
CSS:
.main {
position:relative;
background-color:#aaa;
margin:150px auto 0 auto;
width:50%;
height:300px;
}
.info {
background-color:#ccc;
position:absolute;
width:30%;
top:0;
left:100%;
height:100%;
}
.info div {
position:relative;
right:100%;
opacity:0;
margin:10px 7px 20px 7px;
transition:all .5s ease-in-out;
}
.main:hover .info div:nth-child(1){
transition:all .5s ease-in-out;
right:0;
opacity:1;
}
.main:hover .info div:nth-child(2){
transition:all .5s ease-in-out .1s;
right:0;
opacity:1;
}
.main:hover .info div:nth-child(3){
transition:all .5s ease-in-out .2s;
right:0;
opacity:1;
}
.main:hover .info div:nth-child(4){
transition:all .5s ease-in-out .3s;
right:0;
opacity:1;
}
.main:hover .info div:nth-child(n + 4){
transition:all .5s ease-in-out .4s;
right:0;
opacity:1;
}
My goal is to find a solution that will work regardless of the number of divs within the info div. For instance, if there were 50 divs, I would like each one to display .1s later than the previous. The current example has a fixed number of divs within .info, but in my intended application, the number of divs could vary greatly - it could be 50 or none.
Therefore, I'm looking for a potential Javascript solution that can handle different amounts of divs and replace my existing CSS transition code.