JavaScript to proportionally scale images to fit.

Kangaroo Cove, South Australia Kangaroo Cove, South Australia

Browser support

This JavaScript (version 0.2) has been written for use in a NetNewsWire style and as a result is optimised and tested to function with Safari 3.0.3 (and corresponding webkit in Mac OS X).

Also tested successfully in:

Known to fail in:

Unlikely to work in Internet Explorer

Kangaroo Cove, South Australia


This page demonstrates a jQuery plugin which scales images to fit their parent container.

It is reliant on support for the CSS property max-width to prevent images from being enlarged beyond their native resolution. Resize your browser window to see the change.

For optimal image quality and minimised page weight nothing beats exporting your images to exactly the size they will display on the web page.

Unfortunately image dimensions are often beyond our control. Perhaps JavaScript has the potential unlock those pixels and bring those unruly images into line with our flexible layouts.

Photography and JavaScript by Oliver Boermans.