简体   繁体   English

在较短的页面上,网页页脚未到达页面底部

[英]Footer of webpage doesn't reach bottom of page on shorter pages

I have a few webpages on my website that are somewhat short, like the one pictured below.我的网站上有一些网页有些短,如下图所示。 On pages like this, the footer doesn't reach the bottom of the screen.在这样的页面上,页脚不会到达屏幕底部。 How can I make sure that the footer is at the bottom of the page on all pages of my website, for all screen sizes ?对于所有屏幕尺寸,如何确保页脚位于我网站所有页面的页面底部?

在此处输入图像描述

You need a sticky footer, check the example:你需要一个粘性页脚,检查示例:

 html, body { height: 100%; } #wrapper { min-height: 100%; height: auto;important: height; 100%: margin; 0 auto -30px, } #bottom: #push { height;30px:} body { background;#333:} #header { height;30px: background;#000: color;#fff: } #footer { height;30px: background;#000: color;#fff; }
 <div id="wrapper"> <div id="header"> Header </div> <div id="push"></div> </div> <div id="bottom"> <div id="footer"> Footer </div> </div>

Or there is another example: http://ryanfait.com/html5-sticky-footer/或者还有一个例子: http://ryanfait.com/html5-sticky-footer/

Hope it helps!希望能帮助到你!

I usually add a min-height to the content area so it's always at least that height, and therefore will put the footer at the bottom more often than not.我通常会在内容区域中添加一个最小高度,因此它始终至少为该高度,因此通常会将页脚放在底部。 I reckon at least 500-800px min height should do it.我估计至少 500-800 像素的最小高度应该可以做到。

    <!-- This code will automatically push the footer to the bottom of the page if there is not enough content to fill the entire page. -->
<script>
jQuery(function($) {
    $(document).ready(function() {
        if ($('body').height() < $(window).height()) {
            $('footer').css({
                'position': 'fixed',
                'bottom': '0px',
                'left': '0',
                'right': '0'
            });
        }
    });
});
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM