【问题标题】:stretch div content to the fixed position footer at the bottom of the page将 div 内容拉伸到页面底部的固定位置页脚
【发布时间】:2011-03-12 15:40:52
【问题描述】:

我的页面由4个div组成:顶部是header,中间是menu div和content div,底部是footer 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>

最好的问候, 爪哇

【问题讨论】:

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


    【解决方案1】:

    我假设这就是你所需要的。

    检查工作示例http://jsfiddle.net/hk4p5/2/

    【讨论】:

    • 谢谢侯赛因,这正是我所需要的。
    • 您好,此解决方案适用于 firefox,但不适用于 IE(我使用的是 ie8)。我把文件放在我的网页上。你可以在link查看。我在某个地方发现 IE 不支持同时使用顶部和底部。你知道 IE 的诀窍吗?如果我查看link 的页面,那么它也可以在 IE 中使用。
    猜你喜欢
    • 1970-01-01
    • 2012-08-20
    • 2015-08-10
    • 2011-08-05
    • 2013-09-25
    • 2016-10-03
    • 2022-01-10
    • 1970-01-01
    相关资源
    最近更新 更多