ページの上部にしっかりとしたヘッダーがあり、ページの下部に固定フッターを取得しようとしています。しかし、body と html クラスに問題があります。ページの上部からのヘッダーの高さは 100px、html と body クラスの高さは 100%、フッターは 150px です。私は自分のページにフッターを正しく書いたので、それは一番下にくっつきますが、100% の高さの html または body がページのさらに下に配置されているため、フッターがない場合でもスクロールしてフッターを表示する必要があります。テキストはそれをはるかに押し下げます!ここに私のCSSコードがあります:
html {
height:100%;
background: url(pics/bg.png) no-repeat top center fixed;
margin:0;
padding:0;
}
body {
height:100%;
margin:0;
padding:0;
}
.wrapper {
min-height:100%;
}
.header {
position:fixed;
background:#FFF url(pics/header.png) no-repeat top center fixed;
top:0;
height:100px;
width:1920px;
z-index:1000;
}
.main {
position:absolute;
top:100px;
width:990px;
left:0;
right:0;
overflow:auto;
margin:0 auto;
padding-bottom:150px; /* must be same height as the footer */
padding-top:10px;
padding-left:5px;
padding-right:5px;
}
.footer {
position:relative;
background-image:url(pics/bg_footer.png);
margin-top:-150px; /* negative value of footer height */
height:150px;
width:990px;
margin:0 auto;
clear:both;
}
そして、ここに私のHTMLコードがあります:
<body>
<div class="wrapper">
<div class="header">
</div>
<div class="main">
<p>I can write here</p>
</div>
</div>
<div class="footer">
<p class="alignleft">© Tim</p>
<p class="alignright">17 maart 2013</p>
</div>
</body>
html の高さが 100% であることと関係があるとほぼ確信しています。