Z-index property:

 1) In this example we will use something called z-index property





































We notice that the element which has the sticky div is in top of the Relative div, that means it's in the z-axis of the Relative div. To avoid this situation we can use z-index property.





















Using Z-index property:

































Now we have given the z-index of Relative div as 10px, therefore it's in top of the sticky div. POINT TO BE NOTED IS:

Whoever has the higher Z-index value will float in the top of the element which has lower z-index value than it has.

Comments