I’ve been searching for a javascript to resize an image, if it is larger than the surrounding DIV. The DIV has a relative size, so it depends on the screen resolution of the user, how big the DIV is. Do some of you know a javascript to fix that problem?
@dr__jonesauthorApr 09.2007 — #I was thinking of javascript could read the width of the DIV and the image and if the image was wider than the div, it was scaled down to fit the DIV. it is only a to wide image that brokes the layout, the height doesn't matter.
It is perhaps better to use scale than resize, I'm coding in ASP and my host doesn't support components, so a real resizing is not able afaik.
@gil_davisApr 09.2007 — #Assuming you specify ID for the DIV and the IMG. After the page loads, you can detect the width of the DIV and set the width of the IMG as necessary. Be aware that if you set width on the IMG without setting height, the IMG will keep the aspect ratio. You also need to be aware of padding and borders to get the size right.