Search code examples
csshtmloverlapping

CSS DIV height background image overlapping


I have these two DIV tags with background image.

<div class="content_bg">
    <div id="content">
        <div id="contentLeft">   
        </div>
        <div id="contentRight">            
        </div>
    </div>
</div>
<div class="footer_bg">
    <div id="footer">
        <div id="footerLeft">            
        </div>
        <div id="footerRight">           
        </div>
    </div>
</div>

If I manually set the height of the content, everything looks fine but if I set it to either 100% or Auto, the footer_bg overlap on top of the content_bg. Could someone kindly advice?

/*
====================================================================
Content Area
====================================================================
*/

.content_bg
{
    background:#dadad9 url(images/interior_content_bg_top.jpg) repeat-x center top;

}

#content
{
    width:980px;
    margin:auto;
    height:auto;   
    background:white;     

}

#contentLeft
{
    float:left;
    width:209px; 
    margin-top:50px;   
}


#contentRight
{
    float:right;
    width:770px;     
    font-family: Verdana, Arial, Sans-Serif;
    font-size: 11px;
    line-height:17px;
    border-left:1px solid;
    margin:20px 0 0 0;
}

/*
====================================================================
Footer
====================================================================
*/

.footer_bg
{
    background:#dadad9 url(images/interior_footer_bg.jpg) repeat-x center top;

}

#footer 
{
    width:980px;
    height:258px;
    margin:auto;
    background:#dadad9 url(images/interior_footer.jpg) no-repeat center top;
}
#footerLeft
{
    width:400px;
    height:50px;   
    font-family:Verdana, Arial, sans-serif;
    font-size:11px;    
    line-height:25px;
    float:left;
    padding: 20px 0 0 25px;
    color:#fff;
}


#footerRight
{
    width:100px;
    height:50px;       
    float:right;
    padding: 20px 0 0 0;
}

Solution

  • See the fiddle for code and demo: http://jsfiddle.net/4Ly7E/1/

    Demo: http://jsfiddle.net/4Ly7E/1/embedded/result

    Note: As i dont have background image so i just assume the border of content and footer are the boundaries.

    .content_bg
    {
        background:#dadad9 url(images/interior_content_bg_top.jpg) repeat-x center top;
        border:1px solid red; /* for visiblity */
        overflow:hidden;
    
    }
    
    .footer_bg
    {
        background:#dadad9 url(images/interior_footer_bg.jpg) repeat-x center top;
        border:1px solid teal; /* for visiblity */
        clear:both;
    }