DEV Community

Deepak Poojary
Deepak Poojary

Posted on

CSS Z index and stacking order


This is kind of an advanced property in CSS and all you need to think about here is layers (as in photoshop) and them z index will be a piece of cake for you. All it is do you want a layer or element (let's say Image) to be overlapped or on top.

There is a natural flow of html meaning that elements you code first get displayed first.


Basically you need to know what is absolute, relative and static does. How you change your position of div to absolute is by
position: absolute;}

And how you change z index is like this:( inside any class you want, here z index)

Note: z index property t only works when you have a position of element set to absolute.


Here is a flowchart about z index from Dr Angela Yu which is going to help you if you get stuck somehere

Top comments (0)