HTML/CSS 需要 div 占父级垂直高度的 100%

标签 html css

我正在尝试创建一个以这个 fiddle 为代表的网页...

http://jsfiddle.net/jeljeljel/5BSva/

我希望选项卡下左侧导航的垂直线绘制到位于页面底部的页脚顶部。

页脚功能需要保留。也就是说,如果页面内容没有占据整个页面,页脚将保留在底部。如果页面内容超过视口(viewport)的高度,页脚会被下推。

谁能解决这个问题?这肯定是具有挑战性的。

HTML

<div class="wrapper">
    <div class="header">
        HEADER
    </div>
    <div class="body">


        <ul class="nav nav-tabs" id="tabcontrol">
            <li class="active"><a href="#home" data-toggle="tab">Home</a></li>
        </ul>

        <div class="tab-content">
            <div class="tab-pane active" id="home" style="">
                <div class="navigation" style="">
                    navigation<br />
                    navigation<br />
                    navigation<br />
                </div>
                <div class="content">
                    content
                </div>
            </div>
        </div>


    </div>
    <div class="push">
    </div>
</div>
<div class="footer center">
    <div style="border-bottom: 2px solid rgb(174, 174, 201); background-color: #fff;"></div>
    <div>
        FOOTER
    </div>
</div>

CSS

.body {
    border: 1px solid rgb(174, 174, 201);
    border-top: 5px solid rgb(174, 174, 201);
    border-bottom: 5px solid rgb(174, 174, 201);
    border-left: 2px solid rgb(174, 174, 201);
    border-right: 2px solid rgb(174, 174, 201);
    padding-bottom: 1000px;
    margin-bottom: -1000px;
}

/* Sticky Footer by Ryan Fait (http://ryanfait.com/) */
* {
    margin: 0;
}

html, body {
    height: 100%;
}

.wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto -50px auto; /* the bottom margin is the negative value of the footer's height */
    overflow: hidden;
}

.footer {
    height: 50px;
    background-color: #f8f8f8;
}

.footer, .push {
    height: 50px; /* .push must be the same height as .footer */
    clear: both;
}

form {
    height: 100%;
}
/* Sticky Footer by Ryan Fait (http://ryanfait.com/) */

.navigation {
    float: left;
    width: 150px;
    border-right: 3px solid rgb(174, 174, 201);
    padding-top: 10px;
    white-space: nowrap;
}

.content {
    padding-top: 10px;
}

.nav {
    margin-bottom: 0px;
}

最佳答案

好的。

你只需要让你的列定位绝对,然后调整其余的。
这是您必须添加的代码才能使其正常工作。

.navigation {

    position:absolute;
    bottom:50px;
    top:65px;
        }
.content {
    margin-left:160px;
}

here是你更新的 fiddle 吗(我制作了一个红色的页脚以使其更显眼)
希望这有帮助
干杯

关于HTML/CSS 需要 div 占父级垂直高度的 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15936902/

相关文章:

javascript - 绝对定位元素 - 需要切换可见性

html - 在 Chrome 中鼠标悬停时出现额外像素。双滚动条

javascript - 选定后更改选定的文本

javascript/jQuery 分组元素

jquery - 选中复选框时将类添加到表

html - 如何在不允许多选的情况下在 HTML 中创建列表框?

javascript - 使用javascript计算多个输入值

输入按钮上的 jQuery 动画背景颜色不起作用

css - 为什么 CSS 不支持常量?

html - 向 bx 内容 slider 添加内容