z-index प्रॉपर्टी का उपयोग
z-index प्रॉपर्टी का उपयोग पोजिशन्ड एलिमेंट्स (जिनकी position static के अलावा कुछ भी हो) के स्टैक ऑर्डर को नियंत्रित करने के लिए किया जाता है। नेगेटिव z-index एलिमेंट को उसके पैरेंट के पीछे रखता है।
उदाहरण: इमेज को टेक्स्ट के पीछे रखना
<!DOCTYPE html>
<html>
<head>
<style>
img {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
</style>
</head>
<body>
<img src="https://www.tutorialspoint.com/assets/videotutorials/courses/swift_4_online_training/380_course_210_image.jpg" width="300" height="250">
<p>This is demo text.</p>
</body>
</html>
महत्वपूर्ण: z-index केवल पोजिशन्ड एलिमेंट्स (relative, absolute, fixed, sticky) पर काम करता है।