Reputation: 43
I've got a very high resolution image which is meant to be displayed on any size monitor. The height is to always show in its entirety and the width will be scrollable via JavaScript. The containing element will have an overflow-x set to hidden. My question is how to best handle a variable height and still maintain the correct proportions.
Thanks for any help.
Upvotes: 0
Views: 80
Reputation: 4294
If you only set one of the dimensions (height
or width
, max and min also apply), the other will be scaled proportionally and maintain the aspect ratio.
Upvotes: 1
Reputation: 1452
You can try using the max-height property. The value can be in pixels or percent.
max-height: 100%
Or
max-height: 200px; /* whatever height */
This will constrain the image proportionally.
Upvotes: 0