0

I'm trying to create a modal that has contents of dynamic height that needs to be scrollable if the height of the content goes beyond a certain value but also needs to have certain elements overflow it. To be specific, there are dropdowns within the modal that I don't want to expand the height of the modal but instead overflow the modal's boundaries if they happen to be at the bottom of the modal.

Setting overflow: visible on the modal content achieves this if the modal height is small but then if the height of the modal content increases beyond the height of the viewport, it's obviously unscrollable because of the aforementioned overflow: visible.

I've thought about checking the height of the modal with JS to decide whether it should be overflow: auto or overflow: visible, however that seems like a wonky solution and it means that if the modal is already near viewport height and I set the overflow property to auto to enable scrolling, I still lose the effect I'm looking for, which is for open dropdowns to go outside the modal's boundaries.

Is there a more elegant solution to this?

  • Does this answer your question? [How to limit the height of the modal?](https://stackoverflow.com/questions/28791970/how-to-limit-the-height-of-the-modal) – Christopher Jul 01 '22 at 20:04
  • 1
    You can't have parts of a container be visible when they overflow and other parts be hidden (scrollable). – romellem Jul 02 '22 at 12:45

0 Answers0