Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何正确设置页脚?_Javascript_Html_Css_Footer_Sticky Footer - Fatal编程技术网

Javascript 如何正确设置页脚?

Javascript 如何正确设置页脚?,javascript,html,css,footer,sticky-footer,Javascript,Html,Css,Footer,Sticky Footer,我在网上尝试了很多教程,尝试了javascripts,但对我的页脚没有任何效果。我只是想让它粘到底。如果我在内容位于屏幕下方的页面中修复它,页脚将无法在内容在屏幕大小内的页面中工作。如果我修理一个,另一个就坏了。我怎样才能解决这个问题 在本页中,页脚是正确的: 在本页面中,其位于屏幕中间(您必须滚动): 请帮忙 添加此CSS代码: .wrapper { display: block; } 添加这个css footer { position: fixed; bottom:

我在网上尝试了很多教程,尝试了javascripts,但对我的页脚没有任何效果。我只是想让它粘到底。如果我在内容位于屏幕下方的页面中修复它,页脚将无法在内容在屏幕大小内的页面中工作。如果我修理一个,另一个就坏了。我怎样才能解决这个问题

在本页中,页脚是正确的:

在本页面中,其位于屏幕中间(您必须滚动):

请帮忙

添加此CSS代码:

.wrapper {
    display: block;
}
添加这个css

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

如果页脚是html中的最后一个元素,为什么不试试

body
{
  padding-bottom: 0;
  margin-bottom: 0;
}
footer
{
  margin-bottom: 0;
}
或者,如果整个内容都包装在.container div中,则改为执行以下操作:

.container {   margin-bottom:0;   }
请尝试以下简单代码:

html文件:


positin:绝对值;底部:0?…@安迪试过了。。。它适用于第二个url,但第一个url出现故障。请发布示例代码以复制该问题。两个页面中的cs可能不同,问题的原因可能是任何东西……我们是否应该跟踪链接并调试您的站点。。?事实并非如此。@EApubs您是否尝试添加此CSS:
.wrapper{display:block;}
<div id="header"> Your header </div>
<div id="body"> Your body .. </div>
<div id="footer"> Your footer </div>
#header {
  background-color: blue;
}

#body {
  background-color: green;
  min-height: calc(100vh - 18px - 200px); /* calc(100vh - {{use inspect for height of header}} - {{height of footer}}*/
}

#footer {
  height: 200px;
  background-color: red;
}