演示代码:
<!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-direction: row; *//* 默认值,主轴是水平正向,从左到右 */
/* flex-direction: column; *//* 主轴是垂直正向,从上到下 */
/* flex-direction: row-reverse; *//* 主轴是水平反向,从右到左 */
/* flex-direction: column-reverse; *//* 主轴是垂直反向,从下到上 */
/* flex-wrap: nowrap; *//* 默认值,不换行 */
flex-wrap: wrap;/* 换行,默认交叉轴正向换行 */
/* flex-wrap: wrap-reverse; *//* 换行,交叉轴反向换行 */
/* justify-content: flex-start; *//* 默认值,开始方向对齐 */
/* justify-content: flex-end; *//* 结束方向对齐 */
/* justify-content: center; *//* 居中对齐 */
/* justify-content: space-between; *//* 两端对齐 */
justify-content: space-around;项目之间间隔是两侧间隔*2
}
.wyzx{
width: 120px;height: 50px;line-height: 50px;
background-color: red;text-align: center;color: white;
margin: 10px;
}
</style>
</head>
<body>
<!--
定义是否换行
-->
<!-- ul.box>li.wyzx{我要自学$}*3 -->
<ul class="box">
<li class="wyzx">我要自学1</li>
<li 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 class="wyzx">我要自学7</li>
</ul>
</body>
</html>