Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

forcing an image into a table cell without IMG tag

Status
Not open for further replies.

AGP

Programmer
Sep 11, 2001
97
GB
Can anyone please tell me whether it is possible to force an image into a table cell, so that the whole of the image is displyed (abeit a bit smaller and squashed) without using an image tag. Every method I have tried allows me to place an image in a table cell, but does not force the image to the cell size, so only part of the image is ever displayed.
many thanx in anticipation to your response.
 
Well, you could specify the height and width attributes to be the same as the table cell, which would force the image to be displayed at that size. It won't save any download time as the image will be downloaded at actual size, but the browser will scale it to your specified dimentions. Keep in mind it will distort the image if the sizes are not proportional.
Hope that helps,
PT
ptmon_sm_ribbon.gif
 
Thank you for replying to my question. However, you will have to excuse my ingnorance when it comes to CSS, but how do you set the height and width properties of an image within the style tags?
many thanx.
 
Is there any reason that you don't just set the img size in the img tag?
<table>
<tr>
<td height=125 width=125>
<img src=picture.jpg height=125 width=125></td>
 
Thank you for replying to my question. The reason that I beleive that I cannot use an image tag is that I am trying to create a template system, whereby users can design there own websites.
To do this I have created a page with a small table with three cells representing the users web page. In addition I have set the font size relative to the size of the table representing the window using the scale font function.
From within the same page users can select from a number of colors which are automatically displyed as the background color for the table, or certain cells of the table.
In addition I want the ability for users to select from a number of background images, which when selected will automatically be displyed as the background image for the table. The problem being that I can't use an image tag to set the background for all the cells in the table, and whenever I set the image as the background for the whole table the image is not forced to the same size as the table, but rather only displays part of the image.
I should also mention that for the purpose of displying an image I can't change the layout of the table i.e create only one table cell as there is also text displayed in each of the table cells which are also referenced by other objects.
 
Have you tried using the background image style value for the cell that you want it to appear in?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top