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

Can a BODY BACKGROUND image be "stretched"? 2

Status
Not open for further replies.

BobMCT

IS-IT--Management
Sep 11, 2000
756
0
0
US
I have been searching for this answer without success. I have an image as the background for many of my pages but when viewed on displays with larger resolution (>800 x 600) the images gets tiled. Is there a way to "stretch" it to fit the full landscape of the display area? I've looked at numerious HTML tag options and css options but none seem to address this.
Help? Anyone?
 
You can't stretch an image.

You can use css to center what you do have though...
--------------------------
Code:
body {
font: normal 0.75em/1.5em Verdana, Arial, sans-serif;
padding:0px;
margin:30px 50px 50px 50px;
background: #d0d0d0 url('/ttw2002/i/bigtt_d0d0d0.jpg') center center no-repeat fixed;
/*hor ver*/
color:#339;
}
--------------------------

OR

You can use javascript to detect the screen resolution and write the appropriate line of css (background-image) with the appropriate size image. JimS.
aka
TenTonJim

Looking for work:)
 
You can't stretch a background image, but this is a workaround:

<div style=&quot;position:absolute;top:0;left:0;z-index:0;&quot;>
<img src=&quot;image.gif&quot; width=&quot;100%&quot; height=&quot;100%&quot; >
</div>

Rick
 
Thanks RISTMO for your need workaournd. I tried to incorporate your suggestion into the initial page where needed. However, only then did I realize that the image that needs to be &quot;stretched&quot; to 100% is part of a TABLE tag (i.e.: <table background=&quot;blah.jpg&quot;>).

Is there any way to apply this snippet to a table background?

Thanks in advance.

Bob
 
Sorry, been away for a while. Try this (in the td):

<div style=&quot;position:relative;top:0;left:0;z-index:0;&quot;>
<img src=&quot;image.gif&quot; width=&quot;100%&quot; height=&quot;100%&quot; >
</div>

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top