So, I’m trying to do a modal by doing this:
<div className='transaction-modal'>
<div className='transaction-forms'>
Content of the box modal here
</div>
</div>
And I did this CSS for it:
.transaction-modal {
background-color: rgba(61, 61, 61, 0.48);
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 2;
display: flex;
justify-content: center;
align-items: stretch;
overflow-y: scroll;
}
.transaction-forms {
background-color: white;
border-radius: 20px;
padding: 40px;
max-width: 611px;
justify-content: stretch;
}
But when I tried to use a Lorem500 in the bottom of my modal box HTML, it overflows the box and the .transaction-forms
doesn’t create any white background.
Why does this happen? I think it has something to do about the display: flex
inside the .transaction-modal
, but I just can’t figure out a solution for that.
the form modal
text overflowing the box modal
I want the text to extend the modal box, which means it would create more white background and it doesn’t overflows the box.
3
Answers
try
align-items: center;
instead ofalign-items: stretch;
in transaction-modal class.Set the height of the ‘transaction-forms’ class to ‘fit-content’, it will fix the issue. Also remove ‘justify-content: stretch’.
In transaction forms, adding a max-height and also giving it an overflow-y: auto; to enable it to scroll content if it exceeds the height might help solve the issue.