May which be what you are looking for?
Basically, a different transition-delay used for each row.
I tried to make everything clearer in this fiddle when I was not in the latter. You should really check out the second for a good vue point.
The goal is to display them one at a time. Two solutions for this:
- Unique identifier in a string
- Use nth-child to get each line.
Say we have 3 elements to display in 3s. Here is our timeline:
t Action _____________ 0 | The rectangle begins to display. | 1 | Rectangle at 1/3 of its height. We display our item n° 1. | 2 | Rectangle at 2/3 of its height. We display our item n° 2. | 3 | Rectangle at 3/3 of its height. We display our item n° 3. v
Let revue code:
HTML
<a>Hover me</a> <ul> <li>Hey</li> <li>Hi</li> <li>Ho</li> </ul>
Our goal is simple:
We want that if we drag the cursor over the <a> tag, it will consistently show <ul> and various <li> elements. Moreover, we want it to stay if the mouse is above the menu, but will instantly disappear if the mouse leaves <a> or <ul> .
CSS
The basics
ul { visibility: hidden; background-color: white; height: 0px; border: 1px solid black; } a:hover ~ ul { visibility: visible; background-color: orange; height: 60px; transition: height 3s; }
Now we move on to the "difficult part":
a:hover ~ ul li { opacity: 1; transition: opacity 0.2s; } a:hover ~ ul li:nth-child(1) { transition-delay: 1s; } a:hover ~ ul li:nth-child(2) { transition-delay: 2s; } a:hover ~ ul li:nth-child(3) { transition-delay: 3s; }
And TADAAAAM ! Easy peasy!
On the other hand, to avoid their gradual disappearance:
a ~ ul li { opacity: 0; transition-delay: 0s; } a ~ ul li:nth-child(1) { transition-delay: 0s; } a ~ ul li:nth-child(2) { transition-delay: 0s; } a ~ ul li:nth-child(3) { transition-delay: 0s; }
And here you go. Of course, this is not very dynamic, and if you need to do this for each child, it will soon be boring. But you can use scripts to generate this code. :)
Hope this helps.