如果页面没有太多内容,比如300像素左右,页脚将以1024分辨率显示在页面中间。
我怎么能让我的页脚显示到页面的底部而不知道页脚的高度?
我试过this解决方案:

/* css */
html, body {
    height: 100%;
}

#container {
    min-height: 100%;
    position: relative;
}

#footer {
    position: absolute;
    bottom: 0;
}


<!-- html -->
<html>
<head></head>

<body>
  <div id="container">
    <div id="footer"></div>
  </div>
</body>
</html>

但问题是,我需要在元素的页脚之前添加padding-bottom: (footerheight);。这是不可能的,因为页脚高度是可变的,取决于页面…

最佳答案

为什么不在内容区使用最小高度,所以如果你设置最小高度为600px,如果只有300px的内容,它会把页脚再向下填充300px,这样它就不会在屏幕中间了

关于html - CSS-将FLUID高度页脚贴到页面底部,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4764857/

10-11 23:59
查看更多