1. 01. Incoming
  2. 02. Hifi
  3. 03. Lofi
  4. 04. The Lab
  5. 05. Tags

frequency decoder

Fluid Image Experiment

Posted Sunday October 02, 2005

frequency decoder

A JavaScript attempt at rescaling oversized images to fit their parent containers width

We’ve all seen the problem; one oversized image gets dropped into a fluid layout and things go haywire.

Richard Rutter a.k.a Clagnut has made a valiant attempt at solving the problem using just CSS and, should Internet Explorer not register within your support matrix, a viable CSS solution has been found (See item 8 – bizarrely placed between item 3 and item 4 over at Richard’s demo page, namely, “A medium image with a max-width of 100% and no height set”).

Unfortunately, we still haven’t reached that web development “Shangri-La” in which Internet Explorer can effectively be ignored and so the use of a little JavaScript trickery may be a viable interim solution.

I’ve coded a small experiment that seems to, within the bounds of my minimal testing, successfully rescale oversized images to fit their parent containers width.

There are caveats of course, the solution requires JavaScript to be active and, as usual, a few Internet Explorer quirks need taken into consideration; namely, the requirement of the parent element to have overflow:hidden assigned within the CSS and the use of the non-standard offsetWidth and currentStyle object properties when calculating the parent elements width.

Tested in Internet Explorer 6, Opera 8 and Firefox.

View the fluid image experiment.

Tags: image, javascript

Previous Comments ~

Robert McCrory · http://ssb.okstate.edu/cepd
#1 · Wednesday May 30, 2007

I’m having a problem getting an image to resize in IE and was wondering if you thought that this might help. It works fine in FireFox. Is the code available?

Comments are currently closed for this article but feel free to email me with your input - I’d love to hear it.

Popular Frequencies

  • Unobtrusive Table Sort Script (revi…
    Saturday September 16, 2006
  • Unobtrusive Date-Picker Widget Upda…
    Monday October 02, 2006
  • Unobtrusive Table Sort Script
    Friday November 18, 2005
  • Unobtrusive Date-Picker Widgit
    Friday October 14, 2005
  • Unobtrusive Table Actions Script
    Thursday November 15, 2007

Google Ads

All articles