Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Large image causing table resize

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Hi all

I have a webpage where users can upload an image - the problem is that large images are causing my table to resize and the page to scroll horizontally. Is there any way to force the image to size smaller? I don't want to specify a set height and width as the image may be much smaller than the page.

I've tried setting a static table and column width, setting a div over the whole table and setting the table and column width to a percentage but if the image is too large - it causes scrolling.

Any help would be much appreciated :)

Thanks as always

Craftor
:cool:
 
you can set the overflow property of the table cell using a style sheet.

ie. td { overflow: hidden; }

or something like that anyway

MrBelfry
 
You could use an onLoad event in the picture to check its size and size it down if needed....

function sizeImg(imgID){
thisPic = document.getElementById(imgID)
if (thisPic.height > 100 || thisPic.width > 100){
//you may want to get more specific to prevent distortion
thisPic.height = 100
thisPic.width = 100
}
}


<img src=&quot;someSoure.jpg&quot; id=&quot;myPic&quot; onLoad=&quot;sizeImg('myPic')&quot;>



Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top