2016-03-04 53 views
0

我试图让页面的页脚包含大量图像(因此需要大量滚动),只有在页面滚动完成后才会显示。相反,在发生任何滚动之前,页脚出现在页面的底部,因此在页面中间处于某个笨拙的位置。将页脚保留在页面底部,仅在滚动后出现

相关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> 
       &copy; 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%; 
} 
+1

你试过去掉位置:绝对;从页脚的CSS? –

+0

它做到了,谢谢 – dsideb

+0

我转发了我的评论作为答案。 –

回答

1

取出位置:绝对的;从页脚的css

+0

这不提供问题的答案。要批评或要求作者澄清,请在其帖子下方留言。 - [来自评论](/ review/low-quality-posts/11500939) –

+0

@sebastianbrosch我很抱歉。我没有看到,也没有看到帖子中的任何问题。该帖子提出了一个问题,我只是提供了一个解决方案。此外,根据作者,我的解决方案确实奏效。 –

+0

在我看来这是一条评论,因为你只说“删除这个!” - 添加解释并且不提供低质量的答案! - http://stackoverflow.com/help/how-to-answer –

1

“绝对”的位置,您的页脚的位置是不依赖于内容推下来。它只依赖于父亲的div,其位置是“相对的”。在这种情况下,你的身体标签。如果您给页脚设置了“相对”位置(这是默认设置),则会按照您的要求将其压低。