{"id":14142,"date":"2011-09-06T19:43:53","date_gmt":"2011-09-07T02:43:53","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14142"},"modified":"2022-09-20T10:07:17","modified_gmt":"2022-09-20T17:07:17","slug":"z-index","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/z\/z-index\/","title":{"rendered":"z-index"},"content":{"rendered":"
div {\n z-index: 1; \/* integer *\/\n}<\/code><\/pre>\nThe z-index<\/code> property in CSS controls the vertical stacking order of elements that overlap. As in, which one appears as if it is physically closer to you. z-index<\/code> only affects elements that have a position<\/a> value other than static<\/code> (the default).<\/p>\nElements can overlap for a variety of reasons, for instance, relative positioning has nudged it over something else. Negative margin<\/a> has pulled the element over another. Absolutely positioned elements overlap each other. All sorts of reasons.<\/p>\n<\/figure>\nWithout any z-index<\/code> value, elements stack in the order that they appear in the DOM (the lowest one down at the same hierarchy level appears on top). Elements with non-static positioning will always appear on top of elements with default static positioning.<\/p>\nAlso note that nesting plays a big role. If an element B sits on top of element A, a child element of element A can never<\/strong> be higher than element B.<\/p>\n<\/figure>\nNote that older version of IE get this context stuff a bit screwed up. Here’s a jQuery fix for that<\/a>.<\/p>\nMore Information<\/h3>\n\n- How
z-index<\/code> Works<\/a>\u00a0(screencast)<\/li>\n- Rational
z-index<\/code> Values<\/a><\/li>\n- Understanding
z-index<\/code><\/a>\u00a0(MDN)<\/li>\n<\/ul>\nBrowser Support<\/h3>\n
\n\n\nChrome<\/th>\n Safari<\/th>\n Firefox<\/th>\n Opera<\/th>\n IE<\/th>\n Android<\/th>\n iOS<\/th>\n<\/tr>\n<\/thead>\n \n\nWorks<\/td>\n Works<\/td>\n Works<\/td>\n Works<\/td>\n 4+<\/td>\n 4+<\/td>\n Works<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"div { z-index: 1; \/* integer *\/ } The z-index property in CSS controls the vertical stacking order of elements […]<\/p>\n","protected":false},"author":1036,"featured_media":0,"parent":13961,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-almanac-single.php","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","_share_on_mastodon":"0","_share_on_mastodon_status":"%title% %permalink%"},"tags":[],"acf":[],"share_on_mastodon":{"url":"","error":""},"jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14142"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/1036"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=14142"}],"version-history":[{"count":9,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14142\/revisions"}],"predecessor-version":[{"id":373604,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14142\/revisions\/373604"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/13961"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=14142"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=14142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}