【发布时间】:2018-04-06 21:18:03
【问题描述】:
为什么 z-index 属性不适用于具有绝对位置的元素,如果该元素具有固定位置的父元素? 我为这个案例做了简单的example
HTML:
<div id='q1'>
<div id='q2'></div>
</div>
CSS:
#q1 {
position: fixed;
width: 100%;
height: 50px;
background-color: red;
z-index: 0;
}
#q2 {
position: absolute;
top: 80%;
border: 2px solid black;
width: 100px;
height: 30px;
background-color: green;
z-index: -1;
}
【问题讨论】:
标签: html css css-position z-index