https://developer.mozilla.org/zh-CN/docs/Web/CSS/z-index
一丈积、在 static 中
auto
元素不會(huì)建立一個(gè)新的本地堆疊上下文屑柔。當(dāng)前堆疊上下文中新生成的元素和父元素堆疊層級(jí)相同巷嚣。
<integer>
整型數(shù)字是生成的元素在當(dāng)前堆疊上下文中的堆疊層級(jí)。元素同時(shí)會(huì)創(chuàng)建一個(gè)堆疊層級(jí)為0的本地堆疊上下文。這意味著子元素的 z-indexes 不與元素外的其余元素的 z-index 進(jìn)行對(duì)比盟广。
二、當(dāng)元素設(shè)置position為absolute,relative或者fixed,它們的層疊順序大于position為static的瓮钥。
三 筋量、同一層級(jí)的 absolute ,會(huì)再進(jìn)行 z-index 比較
<style>
? ? .div1 {? position: absolute;? background: red;? z-index: 100;? }
? ? .div2 { position: absolute; background: green;? z-index: 99;}
? ? .div3 {z-index: 101; background: blue; }
</style>
<div class="wrapper">
? ? <div class="div1">11111</div>
? ? <div class="div2">22222</div>
? ? <div class="div3">33333</div>
?</div>