Jump to content
Search Community

Need to define Z depth?

ladlon test
Moderator Tag

Recommended Posts

Hi.  I have an image (consider it an image of a room) in a Bootstrap column, and have a number of additional image elements which are being put on top of that image via position:relative tags... and then animated (rotation, position) via GSAP.  All that is working great.

 

The question I have is, do I need to give each element a specific Z depth value, or will it automatically stack them based on the order that each image tag appears in the code?

 

If I DO have to define a Z depth for each, could someone here please confirm the proper coding for that?

Link to comment
Share on other sites

5 hours ago, ladlon said:

do I need to give each element a specific Z depth value, or will it automatically stack them based on the order that each image tag appears in the code?

By default elements in the DOM are stacked with the first declared on the bottom and the most recently declared on the top. With that being said, a child element is locked into the stacking context of its parent by default so keep that in mind. If you place the images in the order you want them to stack and you never need to change that order then you don't need to use z-index.

 

5 hours ago, ladlon said:

If I DO have to define a Z depth for each, could someone here please confirm the proper coding for that?

It's just a matter of applying the z-index property and value to the elements that you want to apply them to :) If you need help applying them then it'd be helpful for us to see a minimal demo of your situation. The thread below provides more information about how to create that:

 

  • Like 1
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...