background image in a div

This is a discussion on "background image in a div" within the Web Page Design section. This forum, and the thread "background image in a div are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 8th, 2006, 04:09
New Member
Join Date: Oct 2006
Location: UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
background image in a div

heya folks.. I am designing a site using css & php to create pages that open within a div.

The main div has a background image that I wish to remain fixed. You can have a look at the page. If you look in IE, the page looks exactly as I want it... but in Firefox, the background image is somehow in the wrong place... if I remove the "background-attachment: fixed" code, then firefox shows it correctly, but then IE will show a white space under the image if you have to scroll down.......

can anyone help me resolve this, please?

Cheers, BW. x

Last edited by BumbleWeasle; Oct 9th, 2006 at 12:32. Reason: issue now resolved - link removed
Reply With Quote

  #2 (permalink)  
Old Oct 8th, 2006, 10:01
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: background image in a div

Perhaps it has something to do with having the <body> and <html> tags closing twice in different places? Fix all your HTML errors and post back here.
Reply With Quote
  #3 (permalink)  
Old Oct 8th, 2006, 12:35
New Member
Join Date: Oct 2006
Location: UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: background image in a div

Hey, cheers for replying... I should have given you the code for the page...

HTML: Select all
<!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" />
<title>FairMadeMusic :: Michelle Hughes</title>
<style type="text/css">
body {background-color: #666666; font-family: helvetica, arial, sans-serif;}
.main {position:absolute; left:50%; top:50px; width:800px; z-index:1; margin-left:-400px; text-align:right;}
.content {width:568px; height:345px; float:left; padding:15px 30px 5px 32px; margin:5px 0 0 5px; overflow:auto; background-image:url(BoxBack2.jpg); background-attachment:fixed; background-repeat:no-repeat; background-color:#FFFFFF}
.sidebar {width:140px; height:350px; float:right; padding:10px 10px 5px 0; margin:5px 5px 0 0; background-color:#F0F0F0; border-left:4px solid; border-left-color:#666666; background-image:url(BoxBack3.jpg) }
.sidebar a:link, .sidebar a:active, .sidebar a:visited{color:#666666; font-weight:bold; text-transform:lowercase; letter-spacing:-1px; text-decoration:none}
.sidebar a:hover{color:#000000; font-weight:bold; text-transform:lowercase; letter-spacing:-1px} 
.sidebar li{display:block; list-style:none; font-size:1.2em}
p{color:#666666; font-size:85%; text-align:justify}
</style></head>

<body>
<div class="main"><table style="width:800px; height:500px; background-color:#666666"><tr><td valign="top">
<img src="michellehughestitle.gif"style= "width:800px"/>
<div class="content">
<p>
<?php
$page = $_GET['page']
?>
<?php
   switch ($page) {                    
 case "history":                   
           include 'history.html';
           break;                     
       case "music":
           include 'music.html';
           break;
       case "media":
           include 'media.html';
           break;
       case "gigs":
           include 'gigs.html';
           break;
       case "gallery":
           include 'gallery.html';
           break;
       case "community":
           include 'community.html';
           break;
       case "credits":
           include 'credits.html';
           break;
       default:     include 'content.html';             
           break;
   }
   ?>
   </p>
</div>
<div class="sidebar">
<ul>
       <li><a href="index.php?page=home">home</a></li>
       <li><a href="index.php?page=history">history</a></li>
       <li><a href="index.php?page=music">music</a></li>
       <li><a href="index.php?page=media">media</a></li>
       <li><a href="index.php?page=gigs">gigs</a></li>
       <li><a href="index.php?page=gallery">gallery</a></li>
       <li><a href="index.php?page=community">community</a></li>
       <li><a href="index.php?page=credits">credits</a></li>
   </ul>
</div>
<a href="link removed"><img src="myspace.gif" border="0" /></a>
</td>
</tr></table></div>
</body>
</html>
OK... so if you go to the index & "view page source", you see two sets of tags because there are two pages to display in one... the above code is for the page that stays there.. the base, I guess you'd call it... new pages open up in the main (".content") div.. The new pages have nothing but text/content on them...

HTML: Select all
<!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" />
<title>Untitled Document</title>
</head>

<body>
text/content goes here
</body>
</html>
So maybe I have missed something really obvious, but I can't understand how to fix the page as you describe.. can you explain exactly what is wrong with the html please? (I know the text looks stupid at the mo cuz it overlaps the background image.. I'll be fixing that later..)
Cheers!

BW.

Last edited by BumbleWeasle; Oct 9th, 2006 at 12:34.
Reply With Quote
  #4 (permalink)  
Old Oct 8th, 2006, 17:18
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: background image in a div

If I understand correctly what you are showing us, the first set of xhtml is the main page and the second set one of the pages that can be pulled in via the switch statement.

If this is the case, then the pages that are pulled in via the switch statement only require whatever goes where you have the text;

text/content goes here

The rest which identifies the coding for the page and the basic page structure you already have in the main page.
Reply With Quote
  #5 (permalink)  
Old Oct 8th, 2006, 18:37
New Member
Join Date: Oct 2006
Location: UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: background image in a div

OK thanks, that has cleared up my html - but I still have the original problem with the background image. any ideas?
Reply With Quote
  #6 (permalink)  
Old Oct 9th, 2006, 12:37
New Member
Join Date: Oct 2006
Location: UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: background image in a div

OK thanks anyway the problem has now been fixed...

Code: Select all
* html .content{background:#FFFFFF url(BoxBack2.jpg) fixed;}
head+body .content{background:#FFFFFF url(BoxBack2.jpg) no-repeat;}
Reply With Quote
Reply

Tags
ie vs firefox

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 On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fix background image in IE6 tenderfoot Web Page Design 1 Jan 30th, 2008 11:02
how they do the background image act like that ? marSoul Webforumz Cafe 11 Nov 10th, 2007 19:18
background image not big enough mykl Web Page Design 7 Oct 11th, 2007 19:08
Background image overlaping footer image at bottom of div lw_d Web Page Design 4 Mar 21st, 2006 00:27
Need help with my background image!!! courtjester Web Page Design 3 Sep 30th, 2003 15:25


All times are GMT. The time now is 16:37.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43