5

我不确定自己做错了什么,但无法为#content 应用背景颜色。但是如果我将高度值设置为 800 像素,它就可以正常工作。但我希望它是自动或 100%,因为此模板将在整个站点中使用。任何建议将不胜感激。

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

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

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

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

}

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


#contentRight
{
    float:right;
    width:770px; 
    margin:20px 0 0 0;
}

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

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

#footer 
{
    width:980px;
    height:258px;
    margin:auto;
    background:#dadad9 url(images/interior_footer.jpg) no-repeat center top;
}
#footerLeft
{
    width:400px;
    height:50px;       
    float:left;
    padding: 20px 0 0 25px;    
}

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

4 回答 4

18

Set the overflow to auto for #content.

#content {
    width:980px;
    margin:auto; 
    height:auto; 
    background:#fff; 
    overflow:auto;
}
于 2013-02-19T21:12:05.023 回答
4

The problem is that #content has no content. Since you are using height:100% for the div's height, it will expand to the full height of its parent div (i.e. .content_bg). However, .content_bg has no content either; therefore it is expanding to 100% of zero.

于 2013-02-19T21:11:58.913 回答
0

尝试将课程添加到您的 id<div id="content" class="content_bg">并删除课程。并给你的班级这些属性

.content_bg
{
    background-color: white;
    width: 100%;
    height: 100%;
}

然后你的 id "content" 中的内容将定义宽度和高度。

于 2013-02-19T21:18:41.720 回答
0

您在应用背景时遇到问题,#content因为您没有清除浮动。添加

<div style="clear:both"></div>

    <div id="contentLeft">   
    </div>
    <div id="contentRight"> 
        <div id="ContentPane" runat="server" />           
    </div>
于 2013-02-19T21:18:43.903 回答