flex弹性布局中关于设置子项目内部padding的均分问题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
display: flex;
width: 400px;
height: 100px;
}
span {
flex: 1;
}
span:nth-child(2n-1) {
background-color: rebeccapurple;
}
span:nth-child(even) {
background-color: red;
}
span:nth-child(2) {
padding-left: 10px;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="box">
<span>1</span>
<!-- (400-10)/4 +10=107.5 -->
<span>2</span>
<span>3</span>
<span>4</span>
</div>
</body>
</html>