skip to Main Content

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


  1. try align-items: center; instead of align-items: stretch; in transaction-modal class.

    Login or Signup to reply.
  2. Set the height of the ‘transaction-forms’ class to ‘fit-content’, it will fix the issue. Also remove ‘justify-content: stretch’.

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search