Maintain aspect ratios while constraining width and height
-
This is a great plugin, but the default styles are very unforgiving.
For anyone using this plugin, and uploading logos with varying aspect ratios, I would highly recommend adding the following to your CSS:
.logo-container { height: 170px; /* set a fixed height for the container to prevent large fluctuations in logo height */ border: 1px solid #eeeeee; /* add a border so you can see what's happening */ position: relative; /* position relative so the below styles take effect */ } .logo-container img { width: auto; /* allow the widths of logos to vary */ max-height: 80%; /* constrain logo sizes to 80% of the container height */ max-width: 80%; /* constrain logo sizes to 80% of the container height */ position: absolute; /* allow the images to be centred */ top: 50%; /* prepare the images to be centred vertically */ left: 50%; /* prepare the images to be centred horizontally */ transform: translate(-50%, -50%); /* centre both horizontally and vertically */ }
Hope this helps someone …
- The topic ‘Maintain aspect ratios while constraining width and height’ is closed to new replies.