Reply
Two Background Images?
Old 03-14-2008, 08:18 AM Two Background Images?
Extreme Talker

Posts: 195
I am trying to find a way to have two background images.

One will repeat and fill the whole page and the other will be centred and not repeat.

The way I have done it so far is to set the background image of the body style so that it repeats and then I created a DIV and centred it and gave it a background image.

This sort of works but if the users browser is smaller than the centred DIV scroll bars appear, even though there isn't really any content to scroll.

Is there a better way of doing this?

Thank you.
__________________
JF Web Design
Joe3000 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-14-2008, 09:31 AM Re: Two Background Images?
olliebollie's Avatar
Novice Talker

Posts: 10
Name: Oldřich Vetešník
Location: Hradec Králové, Czech Republic
Current CSS doesn't support multiple background images (in-development CSS3 does though). I think you're on a good way with your body background and div background image. Maybe try using "div { width: 200px; margin: 20% auto 0; }" (insert your own widths & heights there...)
__________________
<p style="voice-family: female;">I'm a big man!</p>
olliebollie is offline
Reply With Quote
View Public Profile Visit olliebollie's homepage!
 
Old 03-14-2008, 10:39 AM Re: Two Background Images?
Extreme Talker

Posts: 195
This is the CSS for the DIV I am using for my second background:
Code:
#bg {
    background-image: url(images/logo.gif);    
    width: 800px;
    height: 500px;
    position:absolute;
    top:50%;
    left:50%;
    margin:-250px auto auto -400px;
    text-align:center;
}
I am using margin:-250px auto auto -400px; to center it in the middle of the page.
__________________
JF Web Design
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 03-14-2008, 01:31 PM Re: Two Background Images?
Gilligan's Avatar
Dead Like Me

Posts: 1,608
Name: Stefan
Location: London, UK
Do this instead.

Code:
body {text-align:center;}
adds the page to be centered, don't remove your body code, just add that line.

Code:
#bg {
    background-image: url(images/logo.gif);    
    width: 800px;
    height: 500px;
    margin:0 auto;
    text-align:center;
}
This then centers the div (the margin part)
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 03-14-2008, 02:46 PM Re: Two Background Images?
LadynRed's Avatar
Super Moderator

Posts: 6,403
Location: Tennessee
This - body{text-align: center;} is not necessary, unless you're concerned with IE 5.5 or lower. IE6 now supports the margin:0 auto to center a div.

I do believe your biggest problem is that position:absolute - it's just not a good idea. Learn to use the normal document flow and floats instead.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-15-2008, 11:55 AM Re: Two Background Images?
Extreme Talker

Posts: 195
Is there a better way to center a DIV in the middle in the page than what I am doing now?
__________________
JF Web Design
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 03-17-2008, 02:36 PM Re: Two Background Images?
Gilligan's Avatar
Dead Like Me

Posts: 1,608
Name: Stefan
Location: London, UK
Try my method, maybe?

Twice as easy as what you're doing.
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 04-13-2008, 05:06 AM Re: Two Background Images?
Junior Talker

Posts: 1
You could try using one background picture for the html element, and one for the body element.
sobamushi is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Two Background Images?
 

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15224 seconds with 13 queries