Setting aspect ratios on responsive objects
Responsive design not only caused designers and developers to rethink their entire design process, it caused numerous little head-scratchers along the way.
One problem is how to maintain an an exact aspect ratio on a DOM object on page resize. It’s easy if it contains a presized object, hard if it does not. Adjusting top or bottom padding was always a favorite technique.
Recently I needed a square figure wrapper to contain an image of undetermined size and aspect ratio. The image could be either tall or wide. Despite this, the image would need to center and fill out... More