View Full Version : Image fit to table cell


Trep
07-11-2003, 08:05 AM
First off, I apologize if I put this in the wrong place. I wasn't sure if tables was right because this is more of an image problem.

Second, I'm transfering this question from another board because I just wasn't getting a response. (From now on LEIA will be my first choice)

Here goes:

Ok, I'd like to stay away from javascript and all that.

What I've got is this: A table layed out using only percentages for width and height. (Please don't flame me for this) I have an image that is a bit too wide for one of the cells so it stretches it and breaks the whole table horribly. I've tried width=100% for the image, but I guess specifying a width like that is in relation to the original size of the image. Is there any way to make the image fir snug to the cell?

I haven't tried divs yet, maybe there's something in CSS that can help. Thanks in advance.

I've come to realize this may not be possible without javascript or something like it. Whatever the solution, it's gotta be client-side. And I did try divs, didn't work.

If anymore info is needed, please let me know.

bb_blu
07-11-2003, 10:09 AM
I'm not exactly sure what you're asking.. but if you mean you're simply asking for your image to fit in a table you can just resize the image...
<img src="example.gif" width="numberhere" height="numberhere">

Trep
07-11-2003, 08:53 PM
Ugh, I guess I need to sit down and re-word exactly what I need. I'm so bad at explaining stuff.

I don't want to just resize the pic with static numbers because the thing I'm building is going to be used with multiple resolutions. I can't put width=100% either because that makes the image 100% of its original size. *sigh* I'll have to look into javascript or something to solve this.

christiandude03
07-11-2003, 10:45 PM
when you resize images using only html, they get distorted fast. it's best to simply create a separate image for each resoultion or something like that and then use javascript to choose which image it needs

MaGiCSuN
07-11-2003, 10:52 PM
christiandude03 is right. When you resize an normal image to big, you get pixels. When you make it allot smaller you get a very pixelated (but small pixels) image too. the best is to just edit them in a graphic program because they make them smooth.

but remember, resizing them from 100 to 1000 isn't worth it either, not even with a graphic program. You still get the 'pixelated' look. But from 100 to 400 or so shouldn't be a problem... :)

bellportal
07-12-2003, 08:49 AM
You could find out the height and width of the image and set only the cell the image is in to the exact height and width of the image without using percentages.

You can still use percentages for the rest of your table.

HTH,