Results 1 to 7 of 7

Thread: Background colour for main div

  1. #1
    Join Date
    Mar 2009
    Location
    UK
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Background colour for main div

    What im trying to do is keep the main content and every div within the main div white without having to set the background colour white to each floating div, any help people? Cheers. Code below


    <body>
    <div id="container">
    <div id="left_header">IMAGE HERE</div>
    <div id="right_header">IMAGE HERE</div>
    </div>
    </body>

    body {
    margin: 0;
    padding: 0;
    text-align: center;
    background-image: url(images/background.jpg);
    }
    #container {
    width: 875px;
    text-align: left;
    background-color: #FFFFFF;
    margin-top: 0;
    margin-right: auto;
    margin-bottom: 0;
    margin-left: auto;
    } #left_header {
    width: 207px;
    float: left;
    }
    #right_header {
    width: 668px;
    float: right;
    }

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Add this to your CSS code:
    Code:
    #container {
    width: 875px;
    text-align: left;
    background-color: #FFFFFF;
    margin-top: 0;
    margin-right: auto;
    margin-bottom: 0;
    margin-left: auto;
    overflow: hidden;
    }
    Good luck!

  3. #3
    Join Date
    Mar 2009
    Location
    UK
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Thanks

    Thanks that works quite nicely although I have actually opted to use a small 1pixel image to fill the space below so the container recognizes there's something in it.

  4. #4
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Do you mean a spacer gif? That is really not recommended.

  5. The Following User Says Thank You to Snookerman For This Useful Post:

    sivlock (03-15-2009)

  6. #5
    Join Date
    Mar 2009
    Location
    UK
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    yeah whys that then?

  7. #6
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Yes, spacer gifs were something people used to have to put in if they used tables for layout, with CSS you really shouldn't need to have them.

  8. #7
    Join Date
    Mar 2009
    Location
    UK
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Yeah i see what you mean and works better with the css. Im just starting out using divs and css before I used to use some tables too but i never used spacer gifs.

Bookmarks

Posting Permissions

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