Hey campers,
in the snippet below, you’d expect the two nested divs to be on the same line since their individual width’s (50px) add up to their parent div’s width (100px). can anyone explain why that’s not the case?
https://jsfiddle.net/ahmedgadir/j1qwbz7t/
<head>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.div1 {
background: green;
height: 50px;
width: 100px;
}
.div2 {
height: 50px;
width: 50px;
background: blue;
display: inline-block;
}
</style>
</head>
<body>
<div class='div1'>
<div class='div2'></div>
<div class='div2'></div>
</div>
</body>
when the width of the parent div is increased to 104px then the expected behaviour is observed, however, it doesn’t really make sense as there shouldn’t be any margins separating the divs.
thank you for your time