<分区>
<分区>
Possible Duplicate:
How to make the web page height to fit screen height
我有一个没有占据整个屏幕的 HTML 页面。它只占用 HTML 内容的大小,页脚不在页面末尾(它应该在末尾)
我该如何解决?
我只需要页脚位于页面末尾。
我的 HTML 结构如下:
<body>
<div id="app">
<!-- Header -->
<div id="header"></div>
<!-- Hero container -->
<div class="container">
<!-- Sub container -->
<div class="container"></div>
</div>
<!-- Footer -->
<div id='footer'></div>
</div>
</body>
我的 CSS 如下:
html {
height: 100%;
}
body {
color: hsl(0, 0%, 33%);
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
line-height: 1;
background: none repeat scroll 0 0 hsl(0, 0%, 98%);
margin: 0;
padding: 0;
height: 100%;
}
* {
outline: 0 none;
}
#app {
min-height: 100%;
margin:auto;
width: 100%;
}
div,span,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,a,big,cite,code,del,dfn,em,img,small,strike,strong,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tr,th,td,embed,menu,nav
{
border: 0 none;
font: inherit;
margin: 0;
padding: 0;
vertical-align: baseline;
}
.container {
margin: 0 auto;
position: relative;
width: 990px;
}
#footer {
margin: 100px 0 0;
}
谁能指导我。我是 CSS 的新手。 :( 卡坏了!:(
会不会是因为我在 body 的一些 div 元素中有 float ?
奇怪的是,即使页面很长并且我向下滚动,在页脚之后也有一小条永远不会消失的空白。 当我尝试使用 Firebug 选择空白区域时,它会将我显示为元素。
最佳答案
一种方法是使用 Jquery 将应用程序 div 的最小高度设置为屏幕的高度,这意味着如果内容没有填满屏幕,它仍会填满该高度。 像这样的事情可能会成功:
$(文档).ready(函数() {
var screenHeight = $(document).height();
$('#app').css('最小高度', screenHeight);
});
关于html - 如何让HTML页面占满高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13477169/