Z索引浮动div [英] z-indexing floating divs
本文介绍了Z索引浮动div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个div float:left.我将第一个div索引到上面,但是不起作用.这是因为未定位浮动元素吗?
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>
推荐答案
您需要设置 position
属性.在 #menu
中添加 position:relative
会在拇指上方显示菜单div.
You need to set the position
property. Adding position:relative
to #menu
displays the menu div above thumbs.
这篇关于Z索引浮动div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文