[SOLVED] CSS changing page colour etc

This is a discussion on "[SOLVED] CSS changing page colour etc" within the Web Page Design section. This forum, and the thread "[SOLVED] CSS changing page colour etc 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 Nov 22nd, 2007, 14:29
Reputable Member
Join Date: May 2007
Location: Margate
Age: 24
Posts: 156
Thanks: 0
Thanked 0 Times in 0 Posts
Smile [SOLVED] CSS changing page colour etc

Afternoon,
Please could someone point me in the right direction for the code that is used (similar) in yahoo to change the colours of the background etc.

I know its something to do with linking to another CSS?


All help will greatly appreciated.

Cheers
Dan
Reply With Quote

  #2 (permalink)  
Old Nov 22nd, 2007, 15:23
welshstew's Avatar
Lead Administrator

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,388
Blog Entries: 13
Thanks: 1
Thanked 16 Times in 14 Posts
Re: CSS changing page colour etc

If you have a look at this article it should start you in the right direction.

If you have any more questions then let us know.

Stew
__________________
WelshStew
Lead Administrator

tierney rides tboard - uk site | xtreme wales - extreme clothing
If you think I've helped, click the "Thanks"
webforumz - facebook | LinkedIn
Last Blog Entry: Web Standards Curriculum Launched (Jul 8th, 2008)
Reply With Quote
  #3 (permalink)  
Old Nov 22nd, 2007, 18:14
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS changing page colour etc

This is simply accomplished with css:
Code: Select all
body {
background: #ffffff;
}
Then, change #ffffff (white) to the color you want. That should do it.
If you want to change the background of a div, do this:
Code: Select all
#header {
background: #000000;
}
(#000000 is black!) Then, make the html like this:
HTML: Select all
<div id="header"></div>
Any questions? Just ask...

Cheers
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Reply With Quote
  #4 (permalink)  
Old Nov 22nd, 2007, 20:14
Reputable Member
Join Date: May 2007
Location: Margate
Age: 24
Posts: 156
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS changing page colour etc

swagner
what i am after is buttons that you press and it selects another css.
Reply With Quote
  #5 (permalink)  
Old Nov 22nd, 2007, 20:19
Reputable Member
Join Date: May 2007
Location: Margate
Age: 24
Posts: 156
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS changing page colour etc

http://www.webforumz.com/css-forum/4...yle-sheets.htm

http://www.webforumz.com/css-forum/2...lection-ie.htm

found the info
Reply With Quote
  #6 (permalink)  
Old Nov 22nd, 2007, 20:21
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS changing page colour etc

Ahh, I see. That requires JavaScript, though...
Try this tutorial
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Reply With Quote
  #7 (permalink)  
Old Nov 22nd, 2007, 20:22
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS changing page colour etc

Oh, you got to it before I did. Good luck!
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Reply With Quote
  #8 (permalink)  
Old Nov 22nd, 2007, 20:51
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS changing page colour etc

Until recently, I had about eight stylesheets on my site. I discovered that these were slowing down the initial page load, because each of them generated an http request.

Now, I only have two stylesheets: one for screen, one for print. All of the alternative styles are contained in the screen stylesheet. Instead of using JS to enable/disable stylesheets, I use it to change the class name of the <body> element.

So my styles are like this:

Code: Select all
body {
color: black;
background: white;
}

body.dark {
color: white;
background: black;
}
This accomplishes exactly the same thing, but more efficiently (only one http request instead of [N+1], where N is the number of alternative stylesheets).

The only disadvantage of this method is that it does not allow user agents to provide in-browser stylesheet selection (because all the styles are in one sheet). But this hardly matters, since it's unlikely that many users will dig around in their browser menus to switch styles (how would they even know the styles were available?). IE doesn't provide this option at all.
Reply With Quote
  #9 (permalink)  
Old Nov 22nd, 2007, 20:54
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS changing page colour etc

That's a good idea Mike! Changing the class instead of the stylesheet is much better, and faster...
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Reply With Quote
  #10 (permalink)  
Old Nov 22nd, 2007, 21:07
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS changing page colour etc

Note that you cannot simply use:

Code: Select all
body.className = "dark"
...because this will not work with multiple class names ("dark" will replace all existing class names). You need a way to add and remove class names. Fortunately, you can use this javascript.

This is really useful in other situations too.

I should note that, one day, style switching might become common user behaviour, with prominent, intuitive browser controls. If this ever happens, my method will become bad. But until then, I like my method better.
Reply With Quote
  #11 (permalink)  
Old Nov 27th, 2007, 00:54
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: CSS changing page colour etc

I have created my own customized Page Option almost like what Yahoo have with the help of some webforumz member!

Check out this Thread, I have included the zip file as well for you to try!

Cheers..
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
Reply

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
Green bar of colour at bottom of page gets bigger the more page is extended pixelgirl Web Page Design 1 Apr 1st, 2008 01:27
Changing the colour of the header hunny Web Page Design 4 Oct 5th, 2007 09:44
[SOLVED] Changing pictures on same page R8515198 JavaScript Forum 7 Oct 3rd, 2007 00:14
Help with changing colour of hyperlinks sing2trees Web Page Design 10 May 22nd, 2007 18:08
changing the scroll bar colour bruno89 Web Page Design 2 Oct 6th, 2005 15:12


All times are GMT. The time now is 21:55.


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