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 different backgrounds using external css sheet
Old 08-04-2006, 09:05 AM Two different backgrounds using external css sheet
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
hello all.
This is probably a really stupid question. but I wanted a back ground to my site shown on the below link to my site (The yellow back ground). So I added this code (below) to an external style sheet and it worked.

body {
background-image: url(images/aaabackgroundforweb.jpg);
}

But I want a diferent background for a different part of my site . How do I use this method to have two different backgrounds. I thought of just doing something like -

bodytwo {
background-image: url(different image);
}

And use this in the external style sheet but where on the individual page do I change the code to direct it to bodytwo?

thanks for any help
__________________

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


Please login or register to view this content. Registration is FREE
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
 
Register now for full access!
Old 08-04-2006, 09:38 AM Re: Two different backgrounds using external css sheet
King Spam Talker

Posts: 1,186
Location: Manchester, UK
Trades: 0
You could differentiate the 2 styles by using <body id="style1"> on one page and <body id="style2"> on another page in your html and then use
HTML Code:
#style1 {background-image: url(blah.jpg);}
#style2 {background-image: url(blahblah.jpg);}
gringo is offline
Reply With Quote
View Public Profile Visit gringo's homepage!
 
Old 08-04-2006, 10:21 AM Re: Two different backgrounds using external css sheet
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Another way is to create an internal stylesheet with the same name, which will override the external sheet.
Code:
		<style type="text/css" media="screen"><!--
@import url("main.css");

body {
	background-image: url("newbg.jpg");
}
--></style>
If it's for more than 1 page, you can also just load another stylesheet for those pages (loaded after the main stylesheet) with the same selector and it should override the earlier one.
Code:
@import url("main.css");
@import url("section.css");
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 08-04-2006, 10:40 AM Re: Two different backgrounds using external css sheet
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
thankyou. I'm trying thoughs now. 'funkdaddu' you have given me an idea to duplicate my external sheets and just change the body style on them and then change the linked style sheet for each page i want to change. I think that will work. thanks.
but can I just add another quick small question?....................(OK) thanks.

Is there anyway to use two backgrounds. I want a repeating image for a background y and x. Then I want another repeating images thats just repeats horizontical (x) along the top. The horizontical image will blend into the other background image.
__________________

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


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

Last edited by jason_bristol; 08-04-2006 at 10:45 AM..
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Old 08-04-2006, 11:02 AM Re: Two different backgrounds using external css sheet
King Spam Talker

Posts: 1,186
Location: Manchester, UK
Trades: 0
Could you have the background that repeats x and y specified for <body> but then have the background that repeats only for x specified for a <div>?
gringo is offline
Reply With Quote
View Public Profile Visit gringo's homepage!
 
Old 08-04-2006, 12:02 PM Re: Two different backgrounds using external css sheet
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Quote:
Originally Posted by jason_bristol View Post
'funkdaddu' you have given me an idea to duplicate my external sheets and just change the body style on them and then change the linked style sheet for each page i want to change. I think that will work. thanks.
Why duplicate a stylesheet when you can just add one, tiny stylesheet? If you change a style in your main one, you'll have to make that change in your duped one as well. It's a huge pain (I've made that mistake in the past with print styles). CSS is called Cascading stylesheets for a reason. There's a hierarchy that allows you to override other styles. So why make more work for yourself?

If you want only 1 stylesheet for everything, then gringo's suggestion is the way to go. Name all your pages's body with an id or class, then create a style for each.
Code:
#main {
background-image: url("mainbg.jpg");
}

#contact {
background-image: url("contactbg.jpg");
}

#aboutus {
background-image: url("aboutusbg.jpg");
}
etc...

And the benefit of that way is you can use that to specify other styles, like if you wanted all of the links on your contact page to be underlined, and not on the others:
Code:
#contact a{
text-decoration: underline;
}
And as for the 2 backgrounds, I think I did something similar to what you were talking about with gringo's method here: Student Transportation of America - check the source, I used a BODY background and a DIV called "bg".

Last edited by funkdaddu; 08-04-2006 at 12:11 PM..
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 08-04-2006, 02:10 PM Re: Two different backgrounds using external css sheet
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
Thanks for that bit of follow-up advice. you are right. I did'nt quite understand what to do earlier. but now I do. That way is much better. I'll remember that for my next site.

As for the <div> in the background. I can't do it that way because my site is made up of tables. Unless there is a way to make the 'div wrap' go behind the tables. I don't think there is.

EDIT - sorry i can wrap div tags around tables. I didn't know that. The only way I found I can add this image at the top is to add the tables into a layer. center the table in the layer. Use absolute postioning on this layer with left: 0px; top: 0px and width: 100% Then add a horizontal background across the top of this layer. It works so far.
__________________

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


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

Last edited by jason_bristol; 08-04-2006 at 08:32 PM..
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Reply     « Reply to Two different backgrounds using external css sheet
 

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