Note that there are some explanatory texts on larger screens.

plurals
  1. POZ-index not behaving as expected with absolute positioning inside a fixed position element
    primarykey
    data
    text
    <p>I've got a situation where I've got 2 or more fixed position elements on a page displaying stacked one on top of the other (that is, the top of the second one is abutting the bottom of the first one - no z-index stacking of those elements). Inside the first fixed position element, there's an absolutely positioned element which is taller than its fixed parent, so it extends beyond the bottom of that fixed parent.</p> <p>The trouble is that the next fixed position element gets displayed on top of the absolutely positioned element. I've got a higher z-index value set on the absolutely positioned element than on the fixed positioned elements, but it is ignored completely.</p> <p>To help clarify the issue, I put together this example: </p> <p><strong>HTML</strong> </p> <pre><code>&lt;div class="fixed first"&gt; &lt;p&gt;This is a fixed element&lt;/p&gt; &lt;p class="abs"&gt; I should be displayed above both fixed position elements &lt;/p&gt; &lt;/div&gt; &lt;div class="fixed second"&gt; &lt;p&gt;This is a fixed element&lt;/p&gt; &lt;/div&gt; </code></pre> <p><strong>CSS</strong> </p> <pre><code>.fixed { font-size: 16px; background: #eee; border-bottom: 1px solid #ccc; position: fixed; height: 3em; width: 100%; z-index: 1; } .abs { position: absolute; background: #acc; height: 6em; top: 0; left: 25%; width: 50%; z-index: 2; } .second { top: 3.0625em; } </code></pre> <p>Here's the working example on JSFiddle:</p> <p><a href="http://jsfiddle.net/GS4E4/8/" rel="noreferrer">http://jsfiddle.net/GS4E4/8/</a></p> <p>I'm kind of stumped by this. Does anyone have an explanation as to why this is happening, and a way to work around it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload