如何使用滚动条(溢出时)和底部固定页脚制作自动高度内容?

时间:2010-12-16 14:59:07

标签: html css

model

有可能吗?是|否?|的JavaScript

确定。我会试试。

必须是:

头。固定尺寸,固定位置(顶部)

内容。动态高度取决于窗口,页眉和页脚大小。如果溢出,请滚动。

页脚。始终在底部固定位置。固定尺寸。

窗口。没有滚动(!重要)

PS。到窗口。有一个错误或什么的。如果它是Firefox或Opera键“向下” - 向下滚动。即使“没有滚动” - 隐藏指定。

希望一切顺利


完成。 TNX。

<html>
<head>
<style type="text/css">
* { padding: 0; margin: 0;} /* do not use universal selector this is just for example */
#header{
    top:0;
    left:0;
    right:0;
    height: 150px;
    position:absolute;

}
#content {
    position: absolute;
    bottom: 150px; /*footer height*/
    top:150px; /* header height */
    left: 0;
    right: 0;
    background: yellow;
    overflow: auto;
}

#footer {
    position: absolute;
    height: 150px;
    bottom: 0;
    left: 0;
    right: 0;
    background: red;
}
</style>
</head>
<body>
<div id='header'>
Header content
</div>
<div id="content">
    dynamic content here
</div>
<div id="footer">
</div>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

你真的可以提出一些更好的问题。

<html>
<head>
<style type="text/css">
* { padding: 0; margin: 0;} /* do not use universal selector this is just for example */
#content {
    position: absolute;
    top: 0;
    bottom: 150px;
    left: 0;
    right: 0;
    background: yellow;
    overflow: auto;
}

#footer {
    position: absolute;
    height: 150px;
    bottom: 0;
    left: 0;
    right: 0;
    background: red;
}
</style>
</head>
<body>
<div id="content">
</div>
<div id="footer">
</div>
</body>
</html>

答案 1 :(得分:0)

您好,欢迎来到Stackoverflow,

你可以发一个更具体的问题吗?只是在标题中写一些东西,并有一个真实的问题,如“它可能吗?是|没有| javascript?”对任何人都没有帮助。

回答你的问题:是的,有可能。你只需要使用一些CSS。