Preston
Preston

Reputation: 420

z-indexing floating divs

I have two divs float:left. I z-index the first div to be above, but it doesn't work. Is this because floated elements are not positioned?

<html>

<style>
    #wrap{
        background:#666;
    }

    #menu, #thumbs{
        float:left;
    }

    #menu{
        background:#06C;
        z-index:10;
    }
    #thumbs{
        background:#0CF;
        margin-left:-20px;
    }

</style>
</head>

<body>

<div id="wrap">
    <div id="menu">
    <p>menu</p>
    </div>
    <div id="thumbs">
    <p>thumbs</p>
    </div>
</div>


</body>
</html>

Upvotes: 16

Views: 11556

Answers (1)

anothershrubery
anothershrubery

Reputation: 21023

You need to set the position property. Adding position:relative to #menu displays the menu div above thumbs.

Upvotes: 33

Related Questions