我有两个div:
content2
,它具有我的背景色,并且具有height:auto
和width:100%
content2
中的另一个div称为extensive_look
后者是我的内容的容器,因此具有固定的宽度,居中(带有margin:0 auto
),但没有背景色。想法是,内容将内容结构化为一定宽度,content2
给出了跨越整个页面宽度的背景色。
问题是content2
似乎没有用其背景色覆盖所有内容。
我首先认为可能是因为extensive_look
具有position:relative; top:20px;
,但是即使删除也不能解决问题。
如果您向下滚动到良好示例部分的底部,您会看到背景颜色提前结束,则可以看到here,这是我正在谈论的问题。如何解决此问题?我的代码在下面。
HTML:
<div class="content2">
<div id="extensive_look" style="width: 1000px; margin: 0 auto;
position: relative; top: 20px; height: auto;">
<h1 align="center">Good Website Examples</h1>
<p>Check out these websites for some inspiration...</p>
<div id="white_house" class="ext_image">
<a href="http://www.example.com" target="_blank">
<div class="view_site"></div>
</a>
</div>
<div id="abc" class="ext_image">
<a href="http://www.example.com" target="_blank">
<div class="view_site"></div>
</a>
</div>
<div id="quartz" class="ext_image">
<a href="http://www.example.com" target="_blank">
<div class="view_site"></div>
</a>
</div>
<div id="usatoday" class="ext_image">
<a href="http://www.example.com" target="_blank">
<div class="view_site"></div>
</a>
</div>
</div>
</div>
CSS:
.content2 {
padding: 20px;
background-color: #e0e0e0;
min-height: 500px;
height: auto;
width: 100%;
}
#extensive_look
中的浮动元素。.content2 {
padding:20px;
background-color:#e0e0e0;
min-height:500px;
height:auto;
width:100%;
overflow-y:auto;
}