I'm building a layout with flexbox for my application. The modal where I'm supposed to display the data is centred both vertically and horizontally through the following code:
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 100;
display: flex;
align-items: center;
flex-direction: column;
justify-content: space-around;
margin: auto;
padding: 20px;
overflow-y: auto;
}
When the height is enough to display all the modal it works fine on all browsers, but when the height is not enough even with the scrollbar is impossible to reach the top of the modal:
As you can see from the image even if the scrollbar reached the top corner, there is still part of the modal that is hidden above it. If I remove the property:
justify-content: space-around;
it works, but then the modal si no longer centred:
How can I fix this?