私の理解では、Zインデックスの要素はonly stacked with their siblingsです。私はそのz-index "doesn't work" with position: fixed
も読んだ。しかし、私は一緒に2つを使用していて、それは私がそれを望んでいたものをまさにやってしまった。理由を理解したい。いつ/どのようにしてz-indexはスタッキング・コンテキストを破りますか?
1つの要素を除いてページ内のすべてをカバーする必要があるブロックdivがあります。要素はブロッカーの兄弟ではなく、私はそれが不可能になると思っていましたが、機能しました。ここでどのようなルールが悪用されているのですか?それが他のブラウザでも動作するかどうかはどうすれば予測できますか?
.top {
background-color: yellow;
}
.yes {
position: relative;
z-index: 10;
background-color: blue;
}
.no {
position: relative;
z-index: 1;
background-color: red;
}
.blocker {
position: fixed;
z-index: 5;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .7);
}
<div class="top">
<button class="yes">
Yes
</button>
<button class="no">
No
</button>
</div>
<div class="blocker">
</div>
ご了承ください。 'position:fixed'の要素は' z-index'で動作します。これはあなたにとって有用かもしれません:[** 'z-index'プロパティの基本**](http://stackoverflow.com/a/32515284/3597276) –