我有一个粘性标题,需要一些 z-index 位于页面内容的前面。
粘头scss是:
.sticky-header {
position: sticky;
top: 0;
padding-top: $spacing;
background-color: $background-color;
z-index: 100;
}
在页面的内容中,我有一个“模态视图”,其中包含modal-container我想要显示在整个页面上方的叠加 () 元素。模态 css 看起来像:
.modal-container {
z-index: 3000;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.4);
}
.modal-inner {
z-index: 100;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
出于某种原因,粘性标题显示在模态叠加层上方,即使它明确具有更大的 z-index 值。
html结构的要点是:
<div class="sticky-header">...</div>
<div class="page-content">
<div class="modal-container">
<div class="modal-inner">
...content...
</div>
</div>
</div>
ng-content如果与此问题有关,则粘性标题也会包装一个角度。
任何帮助表示赞赏!