Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Resize background image with css

Reply to topic
Bike Chat Forums Index -> The Geek Zone
View previous topic : View next topic  
Author Message

andrew
Mister Road Rage



Joined: 03 Feb 2002
Karma :

PostPosted: 22:06 - 18 Feb 2007    Post subject: Resize background image with css Reply with quote

I was wondering if anyone on here could help. I'm making a webpage and want to know the best way to get the background image to scale to the size of the page.

The page i'm making is set to 1024x768 using javascript, but i'd like the background image to scale to the size of the window, basically if the visitor maximises the window the image needs to scale.

What is the best way to do this?

After doing a bit of reading i think this will be possible using javascript. Anybody got any ideas how to do it?



Thanks
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

andrew
Mister Road Rage



Joined: 03 Feb 2002
Karma :

PostPosted: 22:42 - 18 Feb 2007    Post subject: Reply with quote

A rather ugly solution but here goes

<html>
<head>
<title>How to stretch a background image.</title>
<style type="text/css">
body {margin:0px;}
#bg_image {
width: 100%;
height: 100%;
left: 0px;
top: 0px;
position: absolute;
z-index: 0;
}
#contents {
z-index: 1;
position: absolute;
}
</style>
</head>

<body>

<!-- this creates the background image -->
<div id="bg_image">
<img src="What Ever.jpg" style="width: 100%; height: 100%;">
</div>

<!-- this puts the contents of the page ontop of the background image -->
<div id="contents">This is a test.</div>
</body>
</html>
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts
Old Thread Alert!

The last post was made 19 years, 6 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.05 Sec - Server Load: 0.58 - MySQL Queries: 14 - Page Size: 31.69 Kb