【问题标题】:Push footer bottom of screen WITHOUT uncessessary scroll在没有不必要滚动的情况下将页脚推到屏幕底部
【发布时间】:2012-07-04 06:35:19
【问题描述】:

好的,所以我已经习惯了与页脚共同的“推送”方法,以确保它停留在页面底部......但是,现在容器和页脚之间有一个不必要的间隙,这意味着总是有向下滚动,即使没有内容可以向下推。我希望如果没有内容,页脚会很好地贴在网站的底部。

有没有其他人发现这个并能够解决它?

提前致谢:)

【问题讨论】:

    标签: html css footer sticky


    【解决方案1】:

    只需几行 CSS 即可完成。假设您使用的是 <footer> 元素,请应用以下样式属性:

    footer {
     position: fixed;
     bottom: 0;
     left: 0;
     width: 100%;
    }
    

    就是这样!

    【讨论】:

      【解决方案2】:

      我用

      #footer {
      position: relative;
      left: 0px;
      bottom: 0px;
      height: 150px; // whatever height you want
      width: 100%;
      }
      

      为我工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-03
        • 1970-01-01
        • 2021-03-25
        • 2016-08-21
        • 1970-01-01
        相关资源
        最近更新 更多