2016-05-31 40 views
0

我是新来的,但我一直在学习过去几年的代码。我刚刚启动了我的网页,除了关于/联系页面外,一切都很好。 页脚没有足够的内容粘贴到底部,粘滞页脚代码使其始终存在。我只希望它位于页面底部和内容下面。在小浏览器上看起来很好,但在大屏幕上或缩小时看起来不错。页脚底部(不粘),即使内容很少

定位绝对和固定不起作用,而底部:0也不起作用。我正在想出如何坚持到底。

任何想法???

这里是我的网站:http://yasminpanjwani.com/aboutcontact.html

谢谢!

+0

的[使躯坚守页面底部正确(http://stackoverflow.com/questions/3443606/make-footer-stick-to-bottom-of-page-correctly) – APAD1

+0

有可能的复制你尝试将这些陈述结合起来......大声笑!适用于我。 APAD1指出这个问题是重复的。 – JoostS

回答

0

你可以计算出视口的高度并设置min-height到您的主元素

如果您使用jQuery

$(document).ready(function() { 

    var viewportHeight = $(document).height(); 

    $('main').css('min-height', viewportHeight - 200); // minus size of your header & footer 

}); 

如果没有;

var $main = document.getElementsByTagName('main'), 
    body = document.body, 
    html = document.documentElement; 

var height = Math.max(
       body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight 
      ); 


$main.style.minHeight = height + 'px';