{"id":1807,"date":"2015-08-31T23:00:50","date_gmt":"2015-08-31T23:00:50","guid":{"rendered":"http:\/\/cssreset.com\/?p=1807"},"modified":"2015-08-31T23:00:50","modified_gmt":"2015-08-31T23:00:50","slug":"z-indexnotworking","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/z-indexnotworking\/","title":{"rendered":"Z-index not working &#8211; troubleshooting"},"content":{"rendered":"<p dir=\"ltr\">The Z-index property can be strange at times. If you don\u2019t have much experience with using it, you might find that it only works most of the time when you need it 100% of the time. Fortunately for you, it isn\u2019t the Z-Index\u2019s fault and there are actually some ways to explain its malfunctions. Here are two common problems that could be causing a headache-inducing Z-Index bug.<\/p>\n<p><strong>1) Not specifying a position for an element.<\/strong><\/p>\n<p dir=\"ltr\">The Z-Index property will simply not work if there isn\u2019t a specific positioning for an element that isn\u2019t static. For example, there are two &lt;div&gt; tags. They both are left as static because they don\u2019t need any fancy additional positioning. The project requires the &lt;div&gt; that is underneath the other to be raised to a higher Z-Index, but when the lower &lt;div&gt; is given the Z-Index property with a higher numeric value nothing seems to happen. This is because the Z-Index does not work with static positioning. Z-Index requires an element\u2019s positioning to be either fixed, relative, or absolute. Judging based on how many times this question has been asked, it is safe to say that this is the most common problem people have with the Z-Index function.<\/p>\n<p dir=\"ltr\"><strong>2) Stacking Contexts.<\/strong><\/p>\n<p dir=\"ltr\">With the Z-Index property there is this poorly documented thing called stacking contexts. Normally an element with a higher Z-Index gets placed above elements with lower Z-Indexes, following common logic. However; stacking contexts can change this in certain circumstances.<\/p>\n<p>Imagine a stack of sheets of paper with drawings on them. The pieces of paper can be rearranged, and the drawings on them can be too, but a drawing on a lower sheet of paper cannot be higher than a drawing on a higher sheet of paper.<\/p>\n<p dir=\"ltr\">This is essentially how stacking contexts work. To translate this into HTML\/CSS terms, replace the sheets of paper with parent elements and the drawings with child elements. If a parent element is positioned below another parent element, then the child elements cannot go higher than an element positioned higher than their parent element. Keep this in mind when using the Z-Index.<\/p>\n<p dir=\"ltr\"><strong>Wrapping Up:<\/strong><\/p>\n<p dir=\"ltr\">The Z-Index property is a powerful tool to arrange elements, but stacking contexts must be considered first. They aren\u2019t as well documented as they should be for such a vital part of Z-Index which makes them tricky for a lot of developers.<\/p>\n<p>Also, remember the basics. Do not use the Z-Index without specifying a position for an element. It will not work!<\/p>\n<p>&nbsp;<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p dir=\"ltr\">The Z-index property can be strange at times. If you don\u2019t have much experience with using it, you might find that it only works most of the time when you need it 100% of the time. Fortunately for you, [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/z-indexnotworking\/\" title=\"Click to read 'Z-index not working &#8211; troubleshooting'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,61,6,7,42],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/1807"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=1807"}],"version-history":[{"count":1,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/1807\/revisions"}],"predecessor-version":[{"id":1808,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/1807\/revisions\/1808"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=1807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=1807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=1807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}