HTML Overlay :: On top of all

Created For: http://stackoverflow.com/questions/10600863/overlaying-divs-with-z-index

by Salustiano Silva

HTML

<div style="z-index:902;">
    <div class="placeOutside" style="position:fixed; z-index:903; right:0; bottom:0; left:0; top:0; background:#ccc;">
        Overlay
    </div>
    <script type="text/javascript">
    jQuery(document).ready(function($) {
        $('.placeOutside').appendTo('body');
    });
    </script>
    Contents of container 1
</div>
<div style="z-index:902;">
    Contents of container 2
</div>
<div style="z-index:902;">
    Contents of container 3
</div>

CSS

div {
    position: relative;
}