我有一个带有粘性页脚的网站,我想在我的 contentContainer 顶部有一个背景图像。有边框很好,但如果我从内容“薄蓝色实心”中删除边框,整个东西都会被推下,我的背景图像不再位于顶部......
<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;
}