Is there a way to center a div on the screen without encountering scrolling issues when the screen size is reduced?
If you have any alternative solutions (excluding the use of transform), please share, as I've tried various approaches but have not been able to successfully center the div on the screen.
.LoginContainer {
background-color: $base;
position: fixed;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
width: 100%;
height: 100%;
overflow: scroll;
}
.LoginBox {
margin: 1rem;
padding: 5rem;
max-width: 30rem;
width: 60%;
position: relative;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
background-color: white;
}
<div class="LoginContainer">
<div class="LoginBox">
TEST
</div>
</div>
You can see the issue I'm facing in this sandbox:
Here are images showing how the component gets clipped when the screen height is reduced: