<div class = "some other divs"></div>
<div class = "some other divs"></div>
<div class = "some other divs"></div>
<div class = "some other divs"></div>
<div class = "main div"></div>
body{
display:flex;
flex-direction:column;
gap:2rem
}
/* just to have som visuals */
div{
background-color:black;
height:50px;
}
.main{
background-color:red;
/* bring it to the top */
order:-1
}
<div class = "some other divs"></div>
<div class = "some other divs"></div>
<div class = "some other divs"></div>
<div class = "some other divs"></div>
<div class = "main div"></div>
<div class="container">
<div class = "some other divs">Item1</div>
<div class = "some other divs">Item2</div>
<div class = "some other divs">Item3</div>
<div class = "some other divs">Item4</div>
<div class = "main div">Item5</div>
</div>
3条答案
按热度按时间rkue9o1l1#
你可以使用css的
flexbox
和它的order
属性,像这样:iqih9akk2#
Youssouf Oumar的回答非常好!另一种方法是使用
grid
:fv2wmkja3#
您可以使用css属性
z-index:
设置每个div的堆栈位置