944,123 Members | Top Members by Rank

Ad:
Sep 1st, 2006
0

Small problem with backgrounds

Expand Post »
I'm not sure exactly how to search for a solution to this problem (unable to articulate it in googlable terms), so I'm posting here.

It should be very simple, all I need to do is start my background with one picture, and then continue the rest of the page with another. The aim is to get a gradually brighter background (first image) and then just a repeating pattern, with the same brightness (second image)

Any help would be appreciated!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Lykil is offline Offline
5 posts
since Sep 2006
Sep 1st, 2006
0

Re: Small problem with backgrounds

You can only have one background, for any given element (such as the body itself). However, you can have an overall background color, with an image fixed at the top that fades into that color.

Have you seen something somewhere close to what you want? Give us a link, and we can likely break it down for you.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Sep 1st, 2006
0

Re: Small problem with backgrounds

Ok, here'sone of my favourite webpages:

www.backstreetboys.com

:o
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Lykil is offline Offline
5 posts
since Sep 2006
Sep 1st, 2006
0

Re: Small problem with backgrounds

Ok, first, three images are used:

http://www.backstreetboys.com//images/bg-4.gif

That is the background image of the body element. So, the entire body of the page is set to that image. It obviously tiles.

Next, we have:

http://www.backstreetboys.com//images/bg-4-gradient.gif

This provides the "fade" effect, and is the background of a div element named "main". The "main" div comes right after/under the body, and everything else is inside of it. The style is set to repeat horizontally, but not vertically. Thus this image marches across the top of the page.

[html]
<html>
<head>
<style type="text/css">
body {
background-image:url(../images/bg-4.gif);
background-position:top center;
}
#main {
background-image:url(../images/bg-4-gradient.gif);
background-position:top center;
background-repeat:repeat-x;
}
#globalWrapper {
background-image:url(../images/shadow-4.gif);
background-position:top center;
background-repeat:no-repeat;
}
</style>
</head>
<body>
<div id="main">
<div id="globalWrapper">
</div>
</div>
<body>
</html>[/html]

Lastly we have the image for the globalWrapper, another div after/under "main". It's too big to place here, but it's basically a "frame" for the page content, and isn't necessary for achieving the background effect.

To summarize: set the background of the "body" tag to your overall repeating pattern. Then place a div just under the body, and set its background to an image that is "darker" at the top, but is an exact match for the overall pattern at the bottom. Set it to repeat horizontally at the top of the page.
Last edited by tgreer; Sep 1st, 2006 at 5:39 pm.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Sep 2nd, 2006
0

Re: Small problem with backgrounds

thanks for the help. got the image loaded up, but div causes a line break before it renders the image. There doesn't seem to be any easy way around.

Wherever I've searched, it has been recommended to use

<div style="display: inline;">


but this just causes the image to disappear again.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Lykil is offline Offline
5 posts
since Sep 2006
Sep 2nd, 2006
0

Re: Small problem with backgrounds

Using the images from the post below, this displayed nicely in IE and Firefox...

[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body {
background-image: url(bg-4.gif);
background-position:top center;
margin: 0px;
padding: 0px;
}
#main {
background-image: url(bg-4-gradient.gif);
background-position:top center;
background-repeat:repeat-x;
height:300px
}

</style>
</head>
<body>
<div id="main">
<div id="globalWrapper">stuff
</div>
</div>
</body>
</html>
[/html]
Team Colleague
Reputation Points: 92
Solved Threads: 21
Posting Pro in Training
FC Jamison is offline Offline
436 posts
since Jun 2004
Sep 2nd, 2006
0

Re: Small problem with backgrounds

That did the trick. Thanks a lot.

Think I learned something new in th process as well. It seems I had placed the "margin: 0px" within the wrong brackets when I tried it.

Btw, can this part of the code from the BSB webpage be viewed?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Lykil is offline Offline
5 posts
since Sep 2006
Sep 2nd, 2006
0

Re: Small problem with backgrounds

Yep, you need to make sure to set the margin and padding of all block level elements to "0" if you want them to abut each other seamlessly.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: schedule html code
Next Thread in HTML and CSS Forum Timeline: finding out variable type from html input type tag in javascsript





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC