内部div需要100%的高度

Sti*_*egt 7 html css

这是我的HTML:

<div id="container">
    <div id="left-container">
    </div>

    <div id="right-container">
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

容器高度为100%(我用Firebug检查过).但是#left_container需要100%也不是!

下面是我的CSS和截图.黄色应为100%.黄色是背景#left-container

html, body {
    height: 100%;
}
#container {
    position:relative;
    margin: 0 auto;
    width: 100%;
    height:100%;
    height: auto !important;
    min-height:100%;
    background: #fff;
}
#left-container {
    width: 300px;
    background: #ff0;
    height:100%;
    height: auto !important;
    min-height:100%;
}
Run Code Online (Sandbox Code Playgroud)

Jam*_*son 7

本文详细讨论了问题和解决方案:

http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks

这也可能有所帮助:

<style>
    #outer {position:absolute; height:auto; width:200px; border: 1px solid red; }
    #inner {position:absolute; height:100%; width:20px; border:1px solid black; }
</style>

<div id='outer'>
    <div id='inner'>
    </div>
    text
</div>
Run Code Online (Sandbox Code Playgroud)

有关上述内容的更多详细信息,请参见此处:
如何使浮动div的父级100%高度?