What is z-index in CSS?
z-index decides which element is on top when elements overlap. An element with a bigger value is shown above those with a smaller value.
.modal { position: fixed; z-index: 100; }
.overlay { position: fixed; z-index: 50; }
It works only on positioned elements (not static) and on flex or grid items. A stacking context can limit its effect. See CSS z-index.
Learn more about the similar topics:
| Tutorials |
|---|
| CSS Layout – The display Property |
| CSS Position Property |
| CSS z-index |
| CSS Float and Clear Property |
| Exercises & Assignments |
|---|
| Write CSS to centre a box horizontally using margin auto |
| Write CSS to create a horizontal navigation menu |