演示代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="reset.css"/>
<style type="text/css">
.box{
width: 400px;height: 400px;background-color: aqua;
margin: 100px auto;overflow: hidden;
display: flex;/* 转成弹性盒子 */
flex-wrap: wrap;
justify-content: space-between;
align-content: space-between;
}
.wyzx{
width: 120px;height: 50px;line-height: 50px;
background-color: red;text-align: center;color: white;
}
#n1{
order: 1;
}
#n2{
order: 2;
}
#n7{
order: 3;
}
</style>
</head>
<body>
<!--
设置弹性元素顺序,order 默认为0
order越小越靠前,拥有相同order不如不设置,按源代码中的顺序进行排列
-->
<!-- ul.box>li.wyzx{我要自学$}*3 -->
<ul class="box">
<li id="n1" class="wyzx">我要自学1</li>
<li id="n2" class="wyzx">我要自学2</li>
<li class="wyzx">我要自学3</li>
<li class="wyzx">我要自学4</li>
<li class="wyzx">我要自学5</li>
<li class="wyzx">我要自学6</li>
<li id="n7" class="wyzx">我要自学7</li>
<li class="wyzx">我要自学8</li>
<li class="wyzx">我要自学9</li>
</ul>
</body>
</html>