两个div z-index覆盖childs z-index

时间:2014-04-04 21:18:26

标签: html css z-index

为什么父母的父级的较高z-index被另一个父级覆盖?

topInner内的top内的bottom<style> .top { width:300px; height:20px; background-color:blue; z-index:30; } .topInner { width: 300px; height: 20px; background-color: green; z-index: 30; text-align:center; } .bottom { width: 300px; height: 60px; background-color: red; z-index: 20; } z-index覆盖。是不是继承了z-index?

我会在这里提供一个代码片段。

<div class="main">
<div class="top">TOP
    <div class="topInner">Inner</div>
</div>
<div class="bottom">Bottom</div>

{{1}}

1 个答案:

答案 0 :(得分:2)

static z-index之外,div的位置应该有效。

工作JSFiddle