Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   HTML / XHTML / CSS (http://www.programmingforums.org/forum27.html)
-   -   fitting image into table cell (http://www.programmingforums.org/showthread.php?t=14592)

jasonfrost Nov 26th, 2007 12:41 PM

fitting image into table cell
 
How can I resize an image to fit it into a table cell? I don't have to use CSS do I? I have just been using "height" and "width" to resize it but it gives you some sort of padding in the cell, throwing off the whole table.

DaWei Nov 26th, 2007 2:01 PM

Re: fitting image into table cell
 
Did you consider showing your code, so we could see how you're doing it? I usually read minds, but it isn't working, today.

I don't see any padding here throwing off the whole table.

titaniumdecoy Nov 26th, 2007 2:56 PM

Re: fitting image into table cell
 
You can use this CSS:

:

table {border-spacing: 0}
table td {padding: 0}


Or this HTML:

:

<table cellspacing="0" cellpadding="0">

Sane Nov 26th, 2007 3:12 PM

Re: fitting image into table cell
 
Is your question how to make an image automatically resize to take up the remaining space in a table cell, if the size of the cell is unknown?

That would very weird if that's your question: I was just trying to figure that out myself this morning. I don't know if it's possible, although I'd like it to be.

DaWei Nov 26th, 2007 3:29 PM

Re: fitting image into table cell
 
If you're putting images with different aspect ratios into adjoining cells, then any "automatic" filling of the cells would lead to distortion. If they all have the same aspect ratio, then just specify the width and height you want in the appropriate places.

If you're using thumbnails, then either make thumbnails of the appropriate size or generate them on the fly on the server side. This will give you control over the resizing algorithm, for greater quality, and will reduce the load time for the page.

A page with just a few images spends much more of its time loading images than it does loading text, even if the text is copious.

titaniumdecoy Nov 26th, 2007 4:34 PM

Re: fitting image into table cell
 
@Sane: You can set the image as the background of the table cell.

DaWei Nov 26th, 2007 6:45 PM

Re: fitting image into table cell
 
...and what does that do, precisely, image wise? Is everything beautiful, or does it suck rose thorns?

titaniumdecoy Nov 26th, 2007 6:53 PM

Re: fitting image into table cell
 
Why would you want to stretch an image to fill a table cell? As you said, the image would be distorted. I assume Sane's intent is to fill cell with an image designed to repeat itself, such as a title bar background.

DaWei Nov 26th, 2007 7:50 PM

Re: fitting image into table cell
 
I wish I could remember the site I went to yesterday. These little flowers were tiled in the background. I wanted to read the text, really I did, which is kind of rare when I find a site that sucks badly ( a circumstance that isn't rare, at all ). I told Firefox to kill the images, I recorded the recipe, then I told my anti-virus software that I didn't ever want to see that site again.

It is unbelievable to me that many sites, which purport to tell one what makes a good site, put dark red text on a black background. "DON'T DO THIS SHIT", they say, then they break all the good rules, because they're merely stupid. I could just shit and fall back in it.

Sane Nov 26th, 2007 9:35 PM

Re: fitting image into table cell
 
I was actually talking about what DaWei said: distorting the image to take up the remaining space. It will have the same aspect ratio, so it's minimal distortion. But height is not known, as it's determined by the adjacent cell's contents.

Anyways, it was just me being curious. I won't continue to hijack this thread. *poof*


All times are GMT -5. The time now is 3:27 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC