dpwh11290 2018-05-07 18:42
浏览 65
已采纳

如何将页脚位置保持在多个页面上的内容之下

So I am learning HTML, CSS, PHP, and I am using php include to add the header & footer I can set the footer to a certain height for each page or set it invidually by creating separate stylesheets.

Is there a way to get the footer to appear under content for every page using php include? When the content is different lengths on each page?

Here is my footer code

HTML

<footer>
  <ul>
    <a href="../../page1.php">
      <li>page1</li>
    </a>
    <a href="../../page2.php">
      <li>page2</li>
    </a>
    <a href="../../page3.php">
      <li>page3</li>
    </a>
    <a href="../../page4.php">
      <li>page4</li>
    </a>
    <a href="../../page5.php">
      <li>page5</li>
    </a>
  </ul>
</footer>

CSS

footer {
  padding: 20px;
  margin-top: 450px;
  height: 1%;
  color: #ffffff;
  background-color: #30323D;
  text-align: center;
}

footer ul {
  margin-left: 0;
  padding: 0;
  list-style-type: none;
  float: left;
}

footer ul a {
  text-decoration: none;
  color: #fff
}

footer p {
  margin-top: 120px;
}

When using position absolute

  • 写回答

3条回答 默认 最新

  • doujimiao7480 2018-05-26 10:46
    关注

    I have been able to fix the issue I was experiencing

    Here is a JSFiddle

    https://jsfiddle.net/lewisjames101/4h20Lwzm/

    HTML
    <div id="container">
    <div id="header">My Header</div>
    <div id="body">Small amount of content</div>
    <div id="footer">My Footer</div>
    </div>
    
    
    
    CSS
    
    html,
    body {
    margin:0;
    padding:0;
    height:100%;
    }
    #container {
    min-height:100%;
    position:relative;
    }
    #header {
    background:#ff0;
    padding:10px;
    }
     #body {
     padding:10px;
     padding-bottom:60px;   /* Height of the footer */
     }
     #footer {
     position:absolute;
     bottom:0;
     width:100%;
     height:60px;   /* Height of the footer */
     background:#6cf;
     }
    

    Thank you for your input, it was helpful

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制