在下面的代码段中,第一行有两个div flex-grow: 1.正如预期的那样,每个div占据屏幕的50%.
向左侧div添加填充时,情况就不再如此.有人可以解释原因吗?
body > div {
height: 50px;
display: flex;
}
body > div > div {
flex: 1;
box-sizing: border-box;
}
#a {
background-color: red;
}
#b {
background-color: green;
}
#c {
padding: 10px;
background-color: blue;
}
#d {
background-color: yellow;
}Run Code Online (Sandbox Code Playgroud)
<div>
<div id="a"></div>
<div id="b"></div>
</div>
<div>
<div id="c"></div>
<div id="d"></div>
</div>Run Code Online (Sandbox Code Playgroud)