There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Background Image


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
stormswimmer's Avatar
Member with 54 posts.
 
Join Date: Oct 2005
28-Apr-2007, 12:29 PM #1
Background Image
Hey everyone,

I am developing a website for a local church with an image for the background. The problem is, that when a computer with a larger screen views the website the picture tiles, and the image was not made to tessellate so it doesn't look right. Is it possible to make the the image stretch instead of tile?

-stormswimmer
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,208 posts.
 
Join Date: Oct 2006
28-Apr-2007, 12:52 PM #2
Got a link or code?
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,109 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
28-Apr-2007, 01:03 PM #3
In the CSS have this:

body {
background-image: url('yourimage.jpg');
background-repeat: no-repeat;
width: 100%;
}

That will have it stretch the image, but not tile it.
stormswimmer's Avatar
Member with 54 posts.
 
Join Date: Oct 2005
28-Apr-2007, 02:57 PM #4
The image doesn't stretch.
jaymanson's Avatar
Computer Specs
Senior Member with 213 posts.
 
Join Date: Mar 2007
Location: Christchurch, New Zealand
Experience: Advanced Design/HTML/CSS - Intermediate PHP
29-Apr-2007, 02:39 AM #5
Quote:
Originally Posted by namenotfound
body {
background-image: url('yourimage.jpg');
background-repeat: no-repeat;
width: 100%;
}
The width value within the body tag will only affect the width of the body of the page - not the width of the background image. There is currently no CSS attribute to do so. However, the same effect can be achieved with a little CSS trickery!

To demonstrate, here's a little code as an example:

HTML
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="styles.css" rel="stylesheet" type="text/css"> <title>Untitled Document</title> </head> <body> <img src="image.jpg" /> <div id="content">CONTENT</div> </body> </html>
CSS
HTML Code:
body img {
	position: absolute;
	left:0px;
	top:0px;
	width: 100%;
	height: 100%;
	z-index: 1;
}

#content {
	position: relative;
	background-color: #FF0000;
	margin: 0 auto;
	height: 500px;
	width: 500px;
	z-index: 2;
}
Replace the image.jpg in the HTML with a path to any image you like. This image sits in the body and the CSS gives it a width and height of 100% stretching it to fill the screen. Remember to use a large sized image as a smaller image will become very pixelated if stretched to fit a large monitor.

All the content goes inside the content div which floats one index higher than the image - you can size and position that anywhere you like; I've just put it there and made it red so it's obvious!

Hope this helps
Reply


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

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
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:50 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.