我試圖讓頁面的頁腳包含大量圖像(因此需要大量滾動),只有在頁面滾動完成後纔會顯示。相反,在發生任何滾動之前,頁腳出現在頁面的底部,因此在頁面中間處於某個笨拙的位置。將頁腳保留在頁面底部,僅在滾動後出現
相關HTML:
<body>
<header>
<a href="index.html" id="logo"> <h1>
<div id="header_title">
Title
</div></h1> </a>
<nav>
<ul>
<li>
<a href="index.html" >About</a>
</li>
<li>
<a href="resume.html">Resume</a>
</li>
<li class="subNav">
<a class="selected" >Portfolio</a>
<ul>
<li>
<a href="writing_samples.html">Writing Samples</a>
</li>
<li>
<a href="photoshop.html">Photoshop</a>
</li>
</ul>
</li>
<li>
<a href="contact.html">Contact</a>
</li>
</ul>
</nav>
</header>
<div id="wrapper">
<section>
<ul id="gallery">
<li>
... images would go here, normally there would be many <li> with content inside them; shortened here for simplicity
</li>
</ul>
</section>
</div>
<footer>
<p>
© 2016 Name.
</p>
</footer>
</body>
和CSS:
html {
height: 100%;
}
body {
font-family: 'Playfair Display', open sans;
position: relative;
height: 100%;
}
footer {
position: absolute;
left: 0;
bottom: 0;
margin-left: auto;
margin-right: auto;
bottom: 0;
font-size: 0.75em;
text-align: center;
clear: both; /* cleared from influence of any other floats
cleared on both left and right sides */
padding-top: 50px;
color: #000000;
width: 100%;
}
你試過去掉位置:絕對;從頁腳的CSS? –
它做到了,謝謝 – dsideb
我轉發了我的評論作爲答案。 –