What is Z-index property in CSS ?

The z-index property in CSS controls the vertical position order of an elements.
An element with greater position order is always use in front & lower in back.

Z-index property:
z-index property is use always greatest position order of an element.

Syntax:-
1
z-index: "position-order";
1
  
Syntax Example:-
1
z-index: 1;
1
  
Example: HTML & CSS code
1
2
3
4
5
6
<div style="background: #cccc; color: white; margin-top: 10px; padding: 45px; position: absolute; z-index: 2;">
Z-index:2</div>
<div style="background: #992211; color: white; margin-left: 50px; margin-top: 80px; padding: 45px; position: absolute; z-index: 3;">
Z-index:3</div>
<div style="background: #006699; color: white; margin-left: 80px; margin-top: 0px; padding: 40px; position: absolute; z-index: 1;">
Z-index:1</div>
Output of Above the Code is as below.

No comments:

Post a Comment