<! DOCTYPE html >
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> div上下左右排序</ title>
</ head>
< style>
.div-box {
display : grid;
grid-auto-flow : column;
grid-template-columns : repeat ( 4, 207px) ;
grid-template-rows : repeat ( 2, 138px) ;
grid-row-gap : 24px;
grid-column-gap : 177px;
}
.div-box2 {
display : grid;
grid-auto-flow : row;
grid-template-columns : repeat ( 4, 207px) ;
grid-template-rows : repeat ( 4, 138px) ;
grid-row-gap : 24px;
grid-column-gap : 177px;
}
.div-item {
background-color : #0ec885;
line-height : 138px;
text-align : center;
}
</ style>
< body>
< h2> 排列:先列后行</ h2>
< div class = " div-box" >
< div class = " div-item" > 1</ div>
< div class = " div-item" > 2</ div>
< div class = " div-item" > 3</ div>
< div class = " div-item" > 4</ div>
< div class = " div-item" > 5</ div>
< div class = " div-item" > 6</ div>
</ div>
< h2> 排列:先行后列</ h2>
< div class = " div-box2" >
< div class = " div-item" > 1</ div>
< div class = " div-item" > 2</ div>
< div class = " div-item" > 3</ div>
< div class = " div-item" > 4</ div>
< div class = " div-item" > 5</ div>
< div class = " div-item" > 6</ div>
< div class = " div-item" > 7</ div>
< div class = " div-item" > 8</ div>
</ div>
</ body>
</ html>