Click to See Complete Forum and Search --> : Image width fit to table cell


Trep
07-09-2003, 02:17 AM
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.

Fang
07-09-2003, 03:09 AM
Try using the image as the background in the table cell.

<td style="background: url(MyImage.gif) no-repeat fixed left;"></td>

You may have to add height and width attributes to the cell to see enough of the image.

Trep
07-09-2003, 03:14 AM
Hrm...I was hoping to maybe use the image as a link, but I'll give that a shot, and if it works I'll call it good. For now at least, keep the suggestions rolling though!

EDIT: Ok, that sorta worked. It fixed the stretching problem, but now part of the image gets chopped to the right. I'm too tired to try and play a little bit more with it tonight. I'll try a few other ideas that sorta popped into my head later.