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