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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Screenwidth Issue?

Status
Not open for further replies.

Linnq

Programmer
Oct 24, 2003
13
CA
This is probably an easy one, I'm having some difficulty getting an image to occupy 100% of a cell in a table.
I'm trying to accomodate high resolutions by stretching a slice taken from the graphic.

Here's the code

<table align=&quot;left&quot; border=&quot;0&quot; width=&quot;100%&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
<tr>
<td valign=&quot;top&quot; width=&quot;623&quot;>
<script LANGUAGE=&quot;JavaScript&quot;>

if (screen.width >= 1024)
{
document.write(&quot;<img src='Images/StaticBannerLarge.jpg','width=623'>&quot;);
}
else
{
document.write(&quot;<img src='Images/StaticBanner.jpg'>&quot;);
}

</script>
</td>
<td valign=&quot;top&quot; width=&quot;100%&quot;>
<script LANGUAGE=&quot;JavaScript&quot;>

if (screen.width >= 1024)
{
document.write(&quot;<img src='Images/SliceLarge.jpg','width=100%,height=94'>&quot;);
}
else
{
document.write(&quot;<img src='Images/Slice.jpg'>&quot;);
}

</script>
</td>
<td valign=&quot;top&quot; width=&quot;271&quot;>
<script LANGUAGE=&quot;JavaScript&quot;>

if (screen.width >= 1024)
{
document.write(&quot;<img src='Images/PhotoLarge.jpg','width=271'>&quot;);
}
else
{
document.write(&quot;<img src='Images/Photo.jpg'>&quot;);
}

</script>
</td>
</tr>
</table>

Any idea's?
 
chagne:
document.write(&quot;<img src='Images/StaticBannerLarge.jpg','width=623'>&quot;);

to:
document.write(&quot;<img src='Images/StaticBannerLarge.jpg' width='623'>&quot;);

does it work now?


Known is handfull, Unknown is worldfull
 
Thanks, I tried that one already. I've tried a few different combinations and haven't had any success. I used the same approach to a banner last year and it worked but it was in html.
 
Use CSS to set the background image of the table and set the tiling to Horizontal only.

Try:

Code:
<style>
 .SliceBackground {
  background-image: url(Images/Slice.jpg);
  background-repeat: repeat-x;
 }
</style>

....

<td class=&quot;SliceBackground&quot; valign=&quot;top&quot; width=&quot;100%&quot;>

Much more eleganter.


Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
 
Thanks dwarfthrower your right. It is much more elegant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top