![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Aug 2007
Posts: 16
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Expert Programmer
|
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"> |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,825
Rep Power: 5
![]() |
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. |
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#6 |
|
Expert Programmer
|
Re: fitting image into table cell
@Sane: You can set the image as the background of the table cell.
|
|
|
|
|
|
#7 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Re: fitting image into table cell
...and what does that do, precisely, image wise? Is everything beautiful, or does it suck rose thorns?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#8 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#10 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,825
Rep Power: 5
![]() |
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* Last edited by Sane; Nov 26th, 2007 at 8:51 PM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing table cell contents using DHTML | eyeball_kid | JavaScript and Client-Side Browser Scripting | 2 | Oct 2nd, 2007 12:32 AM |
| text in a table cell | glevine | JavaScript and Client-Side Browser Scripting | 5 | Jun 12th, 2005 8:37 AM |
| word wrap in a table cell? | kerriganm | HTML / XHTML / CSS | 4 | May 6th, 2005 5:38 PM |
| Checking source codes of image, audio and video files | on_auc | C++ | 3 | Feb 21st, 2005 8:36 PM |
| Change background on a table row (or cell) | kurifu | Java | 2 | Jan 11th, 2005 6:38 PM |