我遇到了一個問題,即當視口縮小到小於爲我的某些元素指定的大小時,背景顏色意外行爲。當滾動條正確顯示時,背景並不是我所期望的。當視口大或大時,背景會按照預期運行。當用Firebug檢查頁面元素時,看起來body
元素即使其內容是內容也不伸縮。什麼導致背景以這種方式表現?導致後臺無法正常顯示的視口寬度
我提供了我認爲是相關的HTML和CSS,但如果我忽略的東西,請讓我知道。
縮水視口例
放大視口例
CSS
html
{
background: #A37C45;
}
body
{
background:
#55688A url("../images/backgrounds/ns_bg.gif") repeat-x scroll 0 0;
}
#container
{
width: 100%;
}
#header
{
width: 730px;
margin-left: auto;
margin-right: auto;
padding: 5px;
overflow: hidden;
}
#main
{
width: 730px;
margin-top: 2px;
margin-left: auto;
margin-right: auto;
overflow: hidden;
}
#footer
{
background:
url("../images/backgrounds/grass.png") repeat-x scroll left top;
clear: both;
width: 100%;
overflow: hidden;
padding-top: 30px;
margin-top: 20px;
}
#footercontainer
{
width: 100%;
background-color: #A37C45;
margin-top: -1px;
}
#footercontent
{
width: 730px;
margin-left: auto;
margin-right: auto;
padding-bottom: 25px;
overflow: hidden;
}
HTML
<html>
<body>
<div id="container">
<div id="header">
</div>
<div id="main">
</div>
</div>
<div id="footer">
<div id="footercontainer">
<div id="footercontent">
</div>
</div>
</div>
</body>
</html>
只好10個像素添加到730px但是這完全成功了! – ahsteele 2010-09-20 20:51:40