Forum Moderators: open

Message Too Old, No Replies

Images in table cells

They resize the cell

         

one_mind

10:02 am on Jul 6, 2006 (gmt 0)

10+ Year Member



Hi,

I have a table layout and I want to place images in the cells without the table changing its dimensions. If the image is bigger that the cell, the cell grows bigger.

Is there a way to stop this? Or do i have to make my images the correct size? Which would be hard because it is fluid and changes size.

Thanks for any info :)

Romeo

10:11 am on Jul 6, 2006 (gmt 0)

10+ Year Member



You may add a width="xx" and a height="yy" to the <img> tag to force the browser to scale the image to the specified limits.
If the xx/yy don't match your image's proportion, the result may look funny, though ...

Kind regards,
R.

penders

2:25 pm on Jul 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Without resizing/distorting the images...

One way is to set the background image of the table cells instead of using an img tag inside the cells and set the size of the cells in the usual way:

#cell1 {
width:100px;
height:150px;
background:url(img/cell1.jpg) 0 0 no-repeat;
}
#cell2 {
width:200px;
height:150px;
background:url(img/cell2.jpg) 0 0 no-repeat;
}

<table>
<tr>
<td id="cell1">&nbsp;</td>
<td id="cell2">&nbsp;</td>
</tr>
</table>

The background images, however, won't get printed by default on most browsers.