.test {
border: 1px solid;
background-color: linen;
padding:5px;
}
.one {
display:inline-block;
padding:10px;
width:70%;
background-color: lightgreen;
}
.two {
display:inline-block;
width:20%;
background-color: lightblue;
}
.sub-one {
background-color: green;
color:white;
margin-bottom:1px;
}
<div class="test">
<div class="one">
<div class="sub-one">first block-level child-element</div>
<div class="sub-one">
second block-level child-element
</div>
</div>
<div class="two">
inline-block sibling
</div>
</div>
So, in this example, the container (test) contains two inline-block elements. So, they both sit inside the line-box of the block container (test). However, why is it that;
If I create a block-level child-element inside the first inline-block (one), why does the content of the block-level child-element sits inside the same line-box with the other sibling inline-block (two)? How are they in the same line-box, since the block-level child-element (sub-one) does not sit inside a line-box?
If I create a second block-level child-elements inside the first inline-block (one), why does the first child-elements gets excluded, and now only the second block-level child-element sits inside a line-box together with the other sibling inline-block (two)?
Here's a snapshot to illustrate my question: