Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Two Background Images?
Old 03-14-2008, 09:18 AM Two Background Images?
Ultra Talker

Posts: 316
Trades: 0
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.
Joe3000 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-14-2008, 10: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
Trades: 0
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, 11:39 AM Re: Two Background Images?
Ultra Talker

Posts: 316
Trades: 0
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.
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 03-14-2008, 02:31 PM Re: Two Background Images?
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
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, 03:46 PM Re: Two Background Images?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
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 !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-15-2008, 12:55 PM Re: Two Background Images?
Ultra Talker

Posts: 316
Trades: 0
Is there a better way to center a DIV in the middle in the page than what I am doing now?
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 03-17-2008, 03:36 PM Re: Two Background Images?
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
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, 06:06 AM Re: Two Background Images?
Junior Talker

Posts: 1
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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 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.26491 seconds with 12 queries