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!

Stretch background image instead of repeating it

Status
Not open for further replies.

OceanDesigner

Programmer
Oct 30, 2003
173
US
I have two images adjacent to each other. The first is written using the <img> tag. The second is used as a hyperlink and is written using the background property of the <td> tag. What I found is that the <img> tag stretches the image to fit and the <td background=""> tag repeats the image to fit. I would like the stretch the latter so there is continuity between the two images. I appreceiate any ideas. The whole code is below:

Code:
<table border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td width="35%" align="right"><img src="left.gif" width="20" height="20"></td>
    <td width="30%" background="images/insidebg.gif" align="center" height="25">
      <a class="white" href="WarrantyReportPrint.asp" target="_blank">
      <b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></b>
      </a>
    </td>
    <td width="35%" align="left"><img src="images/rightcorner.gif" width="20" height="20"></td>
  </tr>
</table>
 
there might be a simpler way but try this:
<td width="35%" align="left"><img src="images/rightcorner.gif" onload="this.width=this.parentNode.offsetWidth" height="20"></td>
 
Looks like my post was unclear. I actually have three images. The first and third (left.gif and rightcorner.gif) work exactly the same through the image tag. It is the middle graphic (insidebg.gif) that I would like to modify so that it gets stretched rather than tiled. It is different because it is used as a background in a cell rather than an image map. I am thinking I may be able to use the style property somehow but I am welcome to any ideas.
 
I'm pretty sure that there's not yet a way to set the dimensions of a background image using css. You may be able to layer a div over an img tag inside your td to achieve the effect though.

 
This is too much trouble. I just stretched the image in MS Photo Editor and saved it as a new file. Good enough.

Thanks,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top