Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 26th, 2007, 11:41 AM   #1
jasonfrost
Newbie
 
Join Date: Aug 2007
Posts: 16
Rep Power: 0 jasonfrost is on a distinguished road
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.
jasonfrost is offline   Reply With Quote
Old Nov 26th, 2007, 1:01 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 26th, 2007, 1:56 PM   #3
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 839
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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">
titaniumdecoy is offline   Reply With Quote
Old Nov 26th, 2007, 2:12 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,825
Rep Power: 5 Sane will become famous soon enough
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.
Sane is offline   Reply With Quote
Old Nov 26th, 2007, 2:29 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 26th, 2007, 3:34 PM   #6
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 839
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Re: fitting image into table cell

@Sane: You can set the image as the background of the table cell.
titaniumdecoy is offline   Reply With Quote
Old Nov 26th, 2007, 5:45 PM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 26th, 2007, 5:53 PM   #8
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 839
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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.
titaniumdecoy is offline   Reply With Quote
Old Nov 26th, 2007, 6:50 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 26th, 2007, 8:35 PM   #10
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,825
Rep Power: 5 Sane will become famous soon enough
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.
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:20 PM.

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