How does z-index work in CSS? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

How does z-index work in CSS?

I have this code for example: <body> <div id="ejemplo1">Hello</div> <div id="ejemplo2">Hello with z-index</div> </body> Css: #ejemplo2{ z-index: ... }

6th Mar 2019, 12:23 PM
Miguel Ángel
Miguel Ángel - avatar
4 Antworten
+ 9
z-index is something like depth of the element. The element with higher z-index will appear the topmost and vice-versa. NOTE: If we get a 3 dimensional plane of the document , we find x(horizontal axis), y(vertical axis) and z(depth)
6th Mar 2019, 12:28 PM
Seniru - avatar
+ 2
Ooh ok men!! Thx Seniru Pasan ­čĹŹ
6th Mar 2019, 12:31 PM
Miguel Ángel
Miguel Ángel - avatar
+ 2
One common use of z-index is to display photos on a page and have them overlapping by using absolute positioning. With z-index, you can specify which images are on top where they overlap. Another common use is when you want a div to overlap a page temporarily, like a welcome message, notification, or an ad. That div would use z-index to cover the page, and would have a javascript link to click on to hide the div.
6th Mar 2019, 3:33 PM
Mike - avatar
Thx men, good answer ­čĹŹ
7th Mar 2019, 2:05 AM
Miguel Ángel
Miguel Ángel - avatar