This doesn't yet make sense to me. What am I missing?
The code is below and on Codepen.
* {
box-sizing: border-box;
margin: 0; padding: 0;
}
body {
height: 100vh;
background: pink;
}
.middle {
position: relative;
top: 200px;
/* uncomment the border to kill the scrollbar! */
/* border: 1px solid green; */
}
.middle div {
margin-top: 100px;
border: 1px dashed yellow;
}
<div class="middle">
<div>Text</div>
</div>
box-sizing: border-box;
doesn't make any difference. Adding a border causes the vertical margins to not collapse, but what exactly is going on?
- with border: no scrollbar
- without border, the two top margins collapse, so there should be less vertical space required, yet we get a vertical scrollbar on the full-height
body
.