开发者

z-indexing floating divs

开发者 https://www.devze.com 2023-02-11 08:31 出处:网络
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?

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>


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

0

精彩评论

暂无评论...
验证码 换一张
取 消