Jump to content
Search Community

Trying to animate a div from the top of the page or relative to another div

Riccardo1091 test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

Hi, I'm trying to animate the blue div from the orange div position to the final position (to the end of the page basically).
Is there a way to make the animation relative to the page so I can use the "h" variable or at least relative to another div, the red one and not relative to itself?
Hope I made myself clear. Thank you.

 

In other words I want the red and the blue div to touch each other, then the blue goes down revealing orange and yellow divs.

 

See the Pen poLGxwE by Mahanon (@Mahanon) on CodePen

Link to comment
Share on other sites

6 minutes ago, Cassie said:

If the divs are always going to be the same height then you can just use yPercent
 

 


If not, could you give a little more context! Thanks

 

 

Unfortunately not, the orange and yellow divs will have different content, I just need an initial animation like a "reveal", two horizontal curtains (red and blue) that open and show orange and yellow. In this animation the only element moving is blue.

 

Basically what u did is good but the other divs will not be the same height as the blue. 

 

EDIT:

Wait a moment, I could calculate the height of the other divs relative to the windows and achieve the result, maybe.....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...