It seems like I'm missing a key point when it comes to my flexbox setup for vertical and horizontal centering.
The issue arises when the container's height exceeds that of its parent, causing the content to extend beyond the top but remain fixed at the bottom due to the presence of a vertical scroll. Give it a try by adjusting the view's height or adding more lines of text.
body,
html {
height: 100%;
width: 100%;
margin: 0;
}
* {
box-sizing: border-box;
}
#wrapper {
background: grey;
height: 100%;
width: 100%;
max-height: 100%;
display: flex;
overflow-y: auto;
align-items: center;
justify-content: center;
}
#box {
margin: 30px 0;
background: white;
border: 1px solid #dfdfdf;
}
<div id="wrapper">
<div id="box">
First line
<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br> Last linje
</div>
</div>
I need help preventing the clipping issue. Additionally, I aim to maintain a 30px margin above and below the container. Any suggestions would be greatly appreciated!
Thank you!