Scaling images for responsive designs


I've had a semblance of a responsive design on my sites for a while, but scaling images continued to elude me. I've always defined the height and width of images, meaning previous attempts at inline scaling resulted in some warped and stretched images.

With some help from Clara, I discovered Rubenerd specifically needed the following lines (your mileage may vary):

#content img {
  height:auto !important;
  max-height:auto !important;

Now images, such as this Railgun image by Dream C Club, will preserve their aspect ratio while scaling up and down. Whether it will improve karaoke abilities is another question.

Author bio and support


Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.