CSS z-index doesn’t do anything, inspector computed style says it’s z-index:auto

Today I fought with a stylesheet for a good 15 minutes, wondering why a content element was overlapping a nav element, and why I couldn’t just give the nav element a higher z-index number. Turns out, z-index is ignored on elements that don’t have a position style attribute.

img {
	z-index: 10000000; /* ignored */
}

img {
	position: relative;
	z-index: 10000000; /* works! */
}
This entry was posted in HTML/CSS and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>