演示代码:
<!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{
background-color: #FF0000;width: 50px;
flex-grow: 1;/* 1/6 */
}
#n2{
background-color: #00ff00;width: 70px;
flex-grow: 2;/* 2/6 */
}
#n3{
background-color: #0000ff;width: 90px;
flex-grow: 3;/* 3/6 */
}
</style>
</head>
<body>
<!--
设置弹性元素扩展比flex-grow来分配剩余空间,默认值为0
-->
<!-- ul.box>li.wyzx{我要自学$}*3 -->
<ul class="box">
<li id="n1" class="wyzx">我要自学1</li>
<li id="n2" class="wyzx">我要自学2</li>
<li id="n3" class="wyzx">我要自学3</li>
</ul>
</body>
</html>