Search code examples
htmlcssmaterialize

Materialize - How do I make a long vertical image stop overflowing inside a modal


I have a long vertical image that overflows from a popup modal causing a scroll wheel to appear. I have already tried to use the responsive-imgclass, but that does not stop the image from overflowing. The only way I can get it to stop is by setting a pixel limit, but that causes the image to look distorted and not responsive.


Solution

  • You can set the image style like this:

    img {
    height: 100%;
    max-width: 100%;
    object-fit: contain;}
    

    It will now 100% height of its parent, in your case is a modal, and the width is responsive.
    Feel free to change it to whatever value you see best.