跳到主要內容

利用 display:flex 的 order 來調整區塊的順序

 [html]

<article>

<div>區塊-1</div>

<div>區塊-2</div>

<div>區塊-3</div>

</article>


[css]

article {

display: -webkit-flex;

display: flex;

-webkit-flex-direction: column;

flex-direction: column;

}

article>div{

padding: 20px;

}

article>div:nth-of-type(1) {

background: #DED561;

}

article>div:nth-of-type(2) {

background: #DC3714;

}

article div:nth-of-type(3) {

background: #5EDCDF;

}


article>div:nth-of-type(1){-webkit-order: 2;}

article>div:nth-of-type(2){-webkit-order: 1;}

article>div:nth-of-type(3){-webkit-order: 3;}

article>div:nth-of-type(1){order: 2;}

article>div:nth-of-type(2){order: 1;}

article>div:nth-of-type(3){order: 3;}