Position: relative; Stack Contexts, Stack Levels and HasLayout

#4 - Final result and Conclusions

div class="a" - This div is just for kicks, removing it does change things slightly, well it did until headings went into place ~ so I think is a collapsing margin side effect, but that's another story


all divs have background color and borders to make the overlap clearer

.a {margin: 20px;}

div class="b" - This div has been given a zero bottom margin to make the overlap clearer

.b {margin: 20px 20px 0 20px;}



div class="c" - This div will be the one to watch ~ for layout or position: relative


it has the negative top margin and zero bottom margin to show it's relationship to previous and following elements

.c {margin: -20px 80px 0 80px; background: #ffc;}
.l {zoom: 1;} 



div class="d" - This is the following block with negative top margin again in order to show the stacking level reverts back

Spacing is controlled by <br> so padding and margins do not affect anything

.d {margin: -20px 50px 0 50px;}




What's happening here, zoom: 1; has been added to div "c" and div "d" in order to set the hasLayout=true on both as explained in demo#3.

The demo now remains stable in both IE6 and IE7B2, well at least more stable that it's been throughout.

I haven't included screenshots here as they are both the same i.e. I couldn't yet get it to break, so you should be viewing the results in IE ~ though it is still not correct, as it is not honouring the stack level for the block level element inside "c", if view in a compliant browser you see the text in "c" is closer to you that d's background and borders, this is correct (does this suggest that haslayout creates a new stacking context?)

Conclusions

Previous : Page 3 Glossary/References  

Claire (Suzy) Campbell «tanfa.co.uk» © 2003-2009