Search code examples
cssz-index

Make a fixed position element appear behind a static position element


How can you make an element that has a position: fixed display behind an element with position: static? Changing z-index doesn't seem to matter since they are not absolute.


Solution

  • You can use negative z-index on the fixed element.

    <div id="fixed">This is fixed</div>
    <div id="static">This is static</div>
    
    #fixed {
        position:fixed;
        z-index:-1;
    }
    

    Fiddle Demonstration