2016-03-04 48 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,其位置是「相對的」。在這種情況下,你的身體標籤。如果您給頁腳設置了「相對」位置(這是默認設置),則會按照您的要求將其壓低。