我试图让页面的页脚包含大量图像(因此需要大量滚动),只有在页面滚动完成后才会显示。相反,在发生任何滚动之前,页脚出现在页面的底部,因此在页面中间处于某个笨拙的位置。将页脚保留在页面底部,仅在滚动后出现
相关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
我转发了我的评论作为答案。 –