Results 1 to 4 of 4
  1. #1
    djb
    djb is offline
    Senior Member djb's Avatar
    Join Date
    Apr 2010
    Location
    Farnham, Surrey
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple style sheets... or is there another way?

    I’m putting together a website at the moment and some of the pages are different widths (don’t ask, not my idea). Ideally I’d just like to have one stylesheet for the whole website just to keep things simple but these three widths need to change depending on the page template being used:

    body { width: 960px; }
    #centre { width: 900px; }
    #centre-nav {width: 880px;}

    Is there a clever way of doing this all in one stylesheet? #centre and #centre nav I could just duplicate and change the names slightly per page, but obviously I can’t do with this body... or can I?

  2. #2
    Senior Member chris_17's Avatar
    Join Date
    Jun 2009
    Location
    Newcastle
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use a body class. So set a body class for each page then just call it in the CSS.

    Example:

    Homepage

    HTML Code:
    <body class="home">
    
    <div id="container">
         <!--Content-->
    </div>
    
    </body>

    Then in the CSS:

    Code:
    body.home #container{
    	width:960px;
    	margin:0 auto;
            ...
    }

    Another Page would be


    HTML Code:
    <body class="about">
    
    <div id="container">
         <!--Content-->
    </div>
    
    </body>

    CSS:

    Code:
    body.about#container{
    	width:460px;
    	margin:0 auto;
            ...
    }

    EDIT: I also dont understand why you are changing the width of the body? It would be more accessible and usable surely if you left it so it could be a bit more responsive???
    Last edited by chris_17; 10-06-2010 at 08:02 PM.
    Front-End Design, Development and Web Standards
    chrisborrowdale.co.uk
    @chrisborrowdale

  3. #3
    djb
    djb is offline
    Senior Member djb's Avatar
    Join Date
    Apr 2010
    Location
    Farnham, Surrey
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got accused of having ‘divitis’ in a previous post, so for this site I decided to try it a different way and set the body width to centre the content. I’d normally use a div to contain all the elements and plonk them in the centre. I may have lost the plot and gone off in the wrong direction though!

    From what you’re saying though, which sounds perfect, I need to do this:

    Code:
    body.960wide { width: 960px; }
    body.960wide#centre { width: 900px; }
    body.960wide#centre-nav {width: 880px;}
    Code:
    <body class="960wide">
    
    <div id="centre">
    
    <div id="centre-nav">
    </div>
    
    </div>
    
    </body>
    And then for the larger pages this:

    Code:
    body.1200wide { width: 1200px; }
    body.1200wide#centre { width: 1140px; }
    body.1200wide#centre-nav {width: 1120px;}
    Have a look if you want, although it’s work in progress and I will be mucking around with the style sheets!

  4. #4
    Junior Member
    Join Date
    Oct 2010
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Make sure the body is set a class and not an ID. It causes less problems with the developers.


Similar Threads

  1. Multiple Small Print Runs?
    By bigdm in forum Tenders & Services Required Forum:
    Replies: 8
    Last Post: 05-25-2011, 07:52 AM
  2. Digital Printing on Vinyl Sheets, Help!
    By emywap in forum Tenders & Services Required Forum:
    Replies: 2
    Last Post: 03-31-2011, 10:40 AM
  3. Multiple Links to same image
    By stablecreative in forum Adobe Forum:
    Replies: 2
    Last Post: 08-11-2010, 10:10 PM
  4. Multiple Radio Buttons
    By OliverB in forum Website Coding & Programming Forum:
    Replies: 1
    Last Post: 07-25-2009, 06:01 PM
  5. Style over substance, but oh what style it is...
    By dot design in forum Website Design Forum:
    Replies: 5
    Last Post: 01-08-2009, 08:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •