Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Max height not creating intended scaling effect

I’d like images to scale to appropriately fit the screen size. I’ve tried a few of the expected things, but they’ve all scaled based on width, and I need something that can scale based on height.

If I use max-width, it works as planned. While if I use max-height, it doesn’t seem to do anything.

<img src="https://i.imgur.com/9OPnZNk.png" style="max-width:20%;height:auto;">

<p>The above scales as intended, and is using the max-width property.</p>

<img src="https://i.imgur.com/9OPnZNk.png" style="width:auto;max-height:20%;">

<p>The above doesn't scale as intended, and is using the max-height property.</p>

How can I fix this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I ran into this issue also and it seems kinda weird sometimes, but if you change max-height:20%; to max-height:20vh;" it works, you scale it then to 20% of the height of the viewport, which gives the same result.

Not a real solution, but a workaround, i hope this helps

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading