使用CSS将position:fixed嵌套元素置于最前面

时间:2018-10-09 12:58:14

标签: html css

我必须将现有网站中的嵌套div放在前面。

我无法更改现有网站(wrapperheader的标记/ css,只能更改div的代码。

是否可以在不删除包装器的.bringMeToFront的情况下,将z-index: 1; div强制成为最前面的元素(也在标头前面)?

HTML:

<body>
<div class="wrapper">

  <div class="bringMeToFront">I would like to be a Frontman.</div>

</div>
 <div class="header">Header</div>
</body>

SCSS:

.wrapper {
  position: relative;
  z-index: 1;
  .bringMeToFront {
    position: fixed;
    text-align: center; 
    padding: 50px;
    left: 0;
    top: 0;
    background-color: orange;
    z-index: 5000;
  }
}
.header {
  width: 100%;
  padding: 20px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1200;
  background: #ffc800;
}

或在Codepen上:https://codepen.io/kmpkt/pen/KGMOVR

0 个答案:

没有答案
相关问题