将div内容拉伸到页面底部的固定位置页脚

时间:2011-02-26 21:11:42

标签: html css position css-float fixed-length-record

我的页面由4divs组成:顶部是标题,中间是菜单div和内容div,底部是页脚div。

页脚应固定在屏幕底部。我想内容div将从标题div延伸到页脚div。如果我使用

position: absolute; 
top: 80px; 
bottom: 30px; 

然后将内容拉伸到页脚,但之后内容不会向右拉伸。请检查以下代码。我希望用红色着色的内容从绿色到黄色垂直拉伸,从蓝色到屏幕右边缘水平拉伸。

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><tiles:insertAttribute name="title" ignore="true" /></title>
        <style>
        html,body{
            margin:0;
            padding:0;
            height:100%;
        }

        #javanus_header{
            height: 80px;
            background:#AAF054;
        }

        #javanus_footer{
            position:absolute;
            bottom:0;
            width:100%;
            height:30px;/* Height of the footer */
            background: yellow;
        }
        #javanus_menu{
            float: left;
            position: absolute;
            top: 80px;
            height:200px;
            width: 200px;
            background: blue;
        }
        #javanus_content{
            height: 300px;
            margin-left: 200px;
            background: red;
            top:100px;
            bottom:50px;
            background-image:url(img/assist.png);
            background-repeat: no-repeat;
            background-position:center;
        }
    </style>
    </head>
    <body>
        <div id="javanus_main">
            <div id="javanus_header">
            </div>
            <div id="javanus_body">
                <div id="javanus_menu">
                </div>
                <div id="javanus_content">
                </div>
            </div>
            <div id="javanus_footer">
            </div>
        </div>
    </body>
</html>

祝你好运, Javanus

1 个答案:

答案 0 :(得分:4)

我认为这就是你所需要的。

检查http://jsfiddle.net/hk4p5/2/

处的工作示例