如何阻止Sticky Footer覆盖内容......?

pia*_*man 13 html css footer css3 sticky-footer

我使用的是"粘性"页脚,但在几页上它覆盖了内容.有没有办法防止这种情况发生,但保留它的"粘性"质量?

我尝试使用min-height:HTMLbody,但没有奏效.

CSS:

html {
    background: black url(images/bg2.jpg) no-repeat 200px center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    height: 100%;
}
body {
    margin: 0;
    height: 100%;
    padding-left: 40px;
    padding-top: 25px;
}
#container {
    min-height: 100%;
    position: relative;
    height: 100%;
    min-width: 900px;
    overflow: hidden;
}
#body {
    padding-bottom: 100px;
    float: left;
    background-color: rgba(0,0,0,0.7);
    width: 750px;
    height: 400px;
}
#footer {
    position: absolute;
    bottom: 0px;
    width: 100%;
    height: 100px;
}
Run Code Online (Sandbox Code Playgroud)

HTML:

<body>

<div id="container">

  <div id="header">
    <div class="logo">C</div>

     <ul class="main_nav">
       <li><a href="index.html">Home</a></li>
       <li><a href="about.html">About</a></li>
       <li><a href="music.html">Music</a></li>
       <li><a href="services.html">Services</a></li>
       <li><a href="gallery.html">Gallery</a></li>
       <li><a href="contact.html">Contact</a></li>
     </ul>
  </div>

  <div id="body">
   <div id="bio_wrapper">

   </div>
  </div>

  <div id="footer">
    <span class="footer_text">Copyright © 2013<br />All Rights Reserved.</span>
  </div>

</div>

</body>
Run Code Online (Sandbox Code Playgroud)

LRA*_*LRA 21

正如amit所说,你应该margin-bottom为你body而使用min-height而不是height:

body {
   min-height: 400px;
   margin-bottom: 100px;
   clear: both;
}
Run Code Online (Sandbox Code Playgroud)

你应该删除100%:高度<body>

希望这可以帮助!


ami*_*osh 7

如果你的身体div在页脚div开始之前关闭,那么使用margin-bottom属性.页面结构的示例

<div id="body">
</div>
<div id="footer">
</div>
Run Code Online (Sandbox Code Playgroud)

然后写

#body{
   margin-bottom: (height of your footer);
}
Run Code Online (Sandbox Code Playgroud)

如果您的代码结构不是那样的.我的意思是你的页脚div在body div里面.然后将该margin margin属性用于在footer div开始之前关闭的div.

  • 页面结构是这样写的,但`margin-bottom:`属性不做任何事情. (2认同)