首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >粘性页脚隐藏内容

粘性页脚隐藏内容
EN

Stack Overflow用户
提问于 2012-12-14 23:26:26
回答 7查看 49.7K关注 0票数 39

我用CSS做了下面的粘性页脚。底部页面的内容目前隐藏在页脚后面(见附件截图)。如何调整CSS以使所有正文内容都可见,并且页脚仍然停留在浏览器窗口的底部?谢谢!

CSS:

代码语言:javascript
复制
.fo {
    position: absolute;
    left: 0;
    bottom: 0;
    height:65px;
    width: 100%;
    color: #eaeaea;
    margin-left: -8px;
}
EN

回答 7

Stack Overflow用户

回答已采纳

发布于 2012-12-15 01:12:42

我以前在互联网上看到过这个答案。效果很好:

HTML

代码语言:javascript
复制
<div id="container">
   <div id="header"></div>
   <div id="body"></div>
   <div id="footer"></div>
</div>

CSS

代码语言:javascript
复制
    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;
}
/* IE 6 and down:
#container {
   height:100%;
}
票数 30
EN

Stack Overflow用户

发布于 2013-08-04 05:04:49

你可以创建一个清晰的div并给它一个高度。

代码语言:javascript
复制
.clear { clear: both; height: 60px; }

<div class="clear"></div>
<div id="footer">FOOTER CONTENT</div>

高度是使内容保持在页脚上方所需的高度,例如。比脚注还高。如果页脚是50px;height,我在透明div中的高度为60px;。因此,当我滚动时,页脚停留在原地,但当我到达底部时,从页脚后面流出的内容有空间被推到页脚上方而不被覆盖。非常简单,而且它工作得很完美。

票数 34
EN

Stack Overflow用户

发布于 2015-12-18 05:34:19

当我想出自己的解决方案时,我也遇到了这个问题。我将我的页脚设置为10%

代码语言:javascript
复制
footer{
  position: fixed;
  **height:10%;**
  width:100%;
  padding-top: 2px;
  bottom: 0;
  clear: both;
  background-color: black;
  color: white;
  float: left;
  overflow: auto;
}

我的内容是拥有一个11%bottom margin

代码语言:javascript
复制
#content{
  width: 800px;
  margin: auto;
  background-color: rgba(0,0,0,.7);
  color: #99FFCC;
  height: 80%;
  padding:30px;
  **margin-bottom: 11%;**
}

我希望这能帮助任何有同样问题的人!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13881548

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档