SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2009
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    div inheriting properties of container??

    i'm trying to make a pretty basic setup.. two body tags in effect, one with a gradient fill and one with a background image.. i have the following

    Code HTML4Strict:
    <body>
    <div id="bg">
    <div id="wrapper">
    </div>
    </div>
    </bg>
    </body>

    and then
    Code CSS:
     
    body {background-color:#e1e1e1;
    background: url(images/bggrad.gif) repeat-x top;}
     
     
     
    /*STRUCTURE*/
    #bg {
    	background: url(images/bgmain.jpg) 50% top no-repeat;
    	}
     
     
    #wrapper {
    	margin: 60px auto 0;
    	width: 844px;
    	background-color: white;
    	}

    the bg div is only as high as the contents of the wrapper div, and starts at 60 pixels down (taking the same margin).. that makes no sense to me, should it not fill the entire page like the body element? that's what i'd like it to do..

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cutcopypaste View Post
    Code HTML4Strict:
    <body>
    <div id="bg">
    <div id="wrapper">
    </div>
    </div>
    </bg>
    </body>
    That </bg> tag is invalid.

    Quote Originally Posted by cutcopypaste View Post
    the bg div is only as high as the contents of the wrapper div
    Yes, the initial value is height:auto, which makes a container adapt its height to its contents.

    Quote Originally Posted by cutcopypaste View Post
    and starts at 60 pixels down (taking the same margin)..
    It's a case of collapsing margins, which is quite according to the CSS specification.

    Quote Originally Posted by cutcopypaste View Post
    should it not fill the entire page like the body element?
    No. Not unless you set a height for it (and for the body element, too).
    Birnam wood is come to Dunsinane

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,276
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    If you want a 100&#37; height container see my answer in this thread.


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
  •