ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

divs and backgroundcolor, best ways?

July 20, 2008 4:41pm

Subscribe [2]
  • #1 / Jul 20, 2008 4:41pm

    wolferey

    33 posts

    So I was wondering what would be a perhaps better way to do this than my current way now.. What I am trying to do is have a bar at the top of the page where login and stuff will be, with a background(color) that streches out as the page/browser stretches out, but with centered content inside. My code goes something like this:


    HTML:

    <div class="bg_color"><div class="width">
    
    <div class="something01">stuff in one collumn</div>
    <div class="something02">stuff in another collumn</div>
    <div class="something03">stuff in last collumn</div>
    
    <div class="clear"><div></div></div>
    </div></div>

    CSS:

    .bg_color { width: 100%; background: #000; }
    .width { width: 960px; margin: 0 auto; }
    
    .something01 { float: left; }
    .something02 { float: left; }
    .something03 { float: left; }
    .clear { clear: both; }


    I need to have a backgroundcolor that stretches across the entire page (not just the 960px). I know this isn’t the best way, but I just keep messing it up any other way ;p

    What would be a better way to do this?

  • #2 / Jul 20, 2008 9:37pm

    Jason Morehead

    456 posts

    I need to have a backgroundcolor that stretches across the entire page (not just the 960px). I know this isn’t the best way, but I just keep messing it up any other way ;p

    What would be a better way to do this?

    Why not just place the background color on your BODY tag?

  • #3 / Jul 20, 2008 10:24pm

    Bruce2005

    536 posts

    Many roads to same mudhole…

    <body>
    <div id="top"> login etc here</div>
    <div id=container">
    rest of page code   etc
    </div>
    </body>
    </html>
    
    #top {
    background: #000;
    color: #FFF;
    width: 100%;
    margin: 0 auto;
    text-align: center;
    padding: 6px 0;
    }
    #container {
    width: 960px;
    margin: 0 auto;
    text: align: center;
    }
    etc…
  • #4 / Jul 21, 2008 8:38am

    wolferey

    33 posts

    opuszine: Because it already has a background image that is supposed to fill the entire page.. should probably have mentioned that, sorry.

    Bruce2005: That will push all my divs to the left side, instead of centering them.


    Should probably extend it a bit, so you see the whole picture:

    <!-- Body has a small repeating bgimage -->
    <body>
    
        <!-- This is the top bar for login/profile etc. with a bgcolor that stretches but with centered content -->
        <div class="bg_color"><div class="width">
    
            <div class="something01">stuff in one collumn</div>
            <div class="something02">stuff in another collumn</div>
            <div class="something03">stuff in last collumn</div>
    
            <div class="clear"><div></div></div>
        </div></div>
    
    
        <!-- This is the content, which is ok since its centered -->
        <div class="width">
            content
        </div>
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases