Html 页脚未位于容器div的底部
我一直试图让我的页脚正确显示,并结合了许多方法,但仍然得到相同的结果。页脚位于距页面顶部一定数量的像素处,不会一直延伸到整个页面。我需要它显示在内容的正下方,无论内容的大小,并且它可以扩展到整个页面 CSS:Html 页脚未位于容器div的底部,html,css,footer,sticky-footer,Html,Css,Footer,Sticky Footer,我一直试图让我的页脚正确显示,并结合了许多方法,但仍然得到相同的结果。页脚位于距页面顶部一定数量的像素处,不会一直延伸到整个页面。我需要它显示在内容的正下方,无论内容的大小,并且它可以扩展到整个页面 CSS: html, body, #container { height: 100%; } #container { height: auto !important; min-height: 100%; margin-bottom:-50px;} #footer { width:100%;
html, body, #container { height: 100%; }
#container { height: auto !important; min-height: 100%; margin-bottom:-50px;}
#footer {
width:100%;
display:block;
background-color:#4a4a4a;
color:#fff;
font-family:'discoregular';
left:-5%;
bottom:0;
top:100%;
height:100%;
text-align:center;
float:left;
position:relative;
body:before;
content:"";
overflow:auto;
margin-top:50px;
padding:10px;
}
#footer, #push{
height:50px;
}
.clearboth {
clear:both;
}
HTML:
<body><div id="container">
<!--Content-->
<div id="push"></div>
</div>
<div class="clearboth"></div>
<div id="footer">Footer Content</div>
页脚内容
您需要确保从html中引用css文件,因此您的html应该如下所示,如果它们位于同一目录中,则无需添加路径:
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="path_to/YOUR_CSS_FILENAME_HERE.css">
</head>
<body><div id="container">
<!--Content-->
<div id="push"></div>
</div>
<div class="clearboth"></div>
<div id="footer">Footer Content</div>
将css更改为以下内容。您可以更改“底部”以便它可以出现
#footer {
width:100%;
display:block;
background-color:#4a4a4a;
color:#fff;
font-family:'discoregular';
left:-5%;
bottom:0;
top:100%;
height:100%;
text-decoration: none;
text-align: center;
width: 100%;
position: fixed;
z-index: 1000;
vertical-align: baseline;
bottom: -50px;
padding:10px;
}读了这篇文章后,我在页脚样式中添加的全部内容是-overflow:auto;-现在它被排序了它链接到了css,我只是没有把它包含在HTML中。哎呀,我刚刚意识到,我编辑了css,这样它就可以解决格式问题了,抱歉!当“位置”设置为“相对”时,页脚从页面顶部开始以固定的像素数显示。当设置为“固定”时,它根本不显示。将位置更改为“固定”怎么样?在#页脚下,#按设置背景色:#000;或者是白色以外的颜色?我更改了我的代码示例以反映此建议。现在它只显示在顶部的固定像素数中。谢谢!但当我将位置更改为“固定”时,页脚根本不会出现。有什么建议吗?
#footer {
width:100%;
display:block;
background-color:#4a4a4a;
color:#fff;
font-family:'discoregular';
left:-5%;
bottom:0;
top:100%;
height:100%;
text-decoration: none;
text-align: center;
width: 100%;
position: fixed;
z-index: 1000;
vertical-align: baseline;
bottom: -50px;
padding:10px;