将页脚保持在滚动水平位置的窗口底部

Bra*_*don 12 html css scroll sticky-footer

我有一个完全水平的滚动网站,

TopNav(固定位置)

导航(固定位置)

内容(横向滚动)

页脚(固定位置)

一切似乎工作得很好,但我遇到的问题是,如果内容足够大,可以水平滚动,它会将页脚放在水平滚动条后面,所以在几页上我创建了#footer {bottom:16px}或者所以要考虑水平滚动条在那里.

我遇到的问题是不同的显示器分辨率.显然,内容将根据窗口大小水平滚动或不滚动.是否有任何方法可以将页脚保持在底部(或水平滚动条上方)无论什么分辨率或窗口大小?

Ger*_*ijk 30

经过大量的反复试验,我发现这是一个始终在底层的最佳解决方案:

HTML:

<div class="footer">

    <div class="footer_contents"></div>

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

CSS:

.footer {

    height:24px; // Replace with the height your footer should be
    width: 100%; // Don't change
    background-image: none;
    background-repeat: repeat;
    background-attachment: scroll;
    background-position: 0% 0%;
    position: fixed;
    bottom: 0pt;
    left: 0pt;

}   

.footer_contents {

    height:24px; // Replace with the height your footer should be
    width: 1000px; // Visible width of footer
    margin:auto;

}
Run Code Online (Sandbox Code Playgroud)

  • 你的修复对我有帮助!我还必须在页脚上方设置div(主div)的下边距,使其大于页脚高度.当页面调整大小时,这可以防止我的页脚覆盖正文内容.希望这可以帮助.`.main {padding:0px 12px; 保证金:12px 8px 40px 8px; 最小高度:420; ```footer {font-family:Arial; 字体大小:13像素; 位置:固定; 底部:0pt; 左:0pt; 宽度:98%; 背景:#272727; 颜色:#fff; text-align:right; 高度:26px; }` (2认同)