頁的底部這是一個示例HTML頁:CSS:位置DIV在
<html>
<body>
<div class="content">
</div>
<footer> </footer>
</body>
</html>
這是我的樣式表:
html {
height: 100%;
}
body {
position: relative;
margin: 0;
height: 100%;
}
.content {
width: 8cm;
position: absolute;
background-color: #ff0;
height: 15cm;
}
footer {
position: absolute;
bottom: 0;
background-color: #f00;
width: 100%;
}
這是它的樣子:
我的問題是,我希望紅色頁腳位於頁面的底部(而不是底部的視口),假設.content
實際上具有可變高度。沒有JavaScript可能嗎?
你的意思是'footer {position:fixed;}'? – Stickers
@sdcr不,如我明確寫的,我*不希望*頁腳留在視口的底部,而是在頁面的底部,即主體。 – theV0ID
在內容和頁腳上都使用'position:absolute'有什麼特別的理由嗎? – Stickers