我有一个带有粘性页脚的网站,我想在我的contentContainer顶部放置一个背景图像。带有边框是可以的,但是如果我从内容中删除边框"thin blue solid",整个内容将被向下推,我的背景图像不再位于顶部...
<div id="mainContain">
<div id="header"></div>
<div id="contentContain">
<div id="content">
<h2>Hog</h2>
</div>
</div>
<div id="footer"></div>
</div>
我的CSS代码如下:
html, body {
padding: 0;
margin: 0;
height: 100%;
}
#mainContain {
min-height: 100%;
position:relative;
}
#header {
width: 100%;
height: 180px;
background-color: #111111;
}
#contentContain {
background-image: url('../img/shadow-bg.png');
background-position: center top;
background-repeat: no-repeat;
padding-bottom: 45px; /* This value is the height of your footer */
}
#content {
margin: auto;
border: thin blue solid;
}
#footer {
position: absolute;
Width: 100%;
bottom: 0;
height: 45px; /* This value is the height of your footer */
background-color: #111111;
}