将div移至CSS [duplicate]中

问题描述 投票:1回答:1

我有2个部分标题和main(红色的)。我将z-index设置为100,并想将主要部分放在前面,但它又往后退,我想知道是什么原因导致CSS?

#red {
    margin-top: -10px;
    background-color: red;
    height: 100px;
    z-index: 100;
}

.img-fluid {
    max-width: 100%;
    height: auto;
}
    <header style="background-color: black;">
        <img class="img-fluid" src="https://via.placeholder.com/1000x100" />
    </header>

    <main id="red" role="main">        
      <div class="container">
          Red
      </div>
    </main>

demo in fiddle

我有2个部分标题和main(红色的)。我将z-index设置为100,并想将主要部分放在前面,但它又往后退,我想知道是什么原因导致CSS? #red {margin-top:-10px; ...

css
1个回答
0
投票

看一下有关z-index的链接:

© www.soinside.com 2019 - 2024. All rights reserved.