滚动条内固定100%div没有Javascript

Mir*_*ate 4 html css scrollbar

好吧,所以我div在屏幕的右侧有一个固定的高度window.当内容超出空间时div,我希望div溢出一个scrollbar.

我已经设法在Chrome中执行此操作,但它在Firefox中无效.

SSCCE

HTML:

<div id="outer">
    <div id="middle">
        <div id="inner">
        </div>    
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

div#outer{
    position    : fixed;
    top         : 0;
    right       : 0;
    display     : table;
    z-index     : 200;
    width       : 320px;
    height      : 100%;
}

div#middle {
    display     : table-cell !important;
    max-width   : 300px;
max-height  : 100%;
}

div#inner {
    overflow-y: auto;
    height: 100%;
}
Run Code Online (Sandbox Code Playgroud)

为什么不起作用?我该怎么办才能修复它?

我意识到我可以将事件绑定到窗口重新调整大小并强制div基于此设置高度,但我更喜欢一个CSS解决方案.

Nic*_*o O 9

使用overflow:auto; 绝对.http://jsfiddle.net/NicoO/49SY8/

body, html
{
    margin:0;
    padding:0;
    height:100%;
}

div#outer{
    position    : fixed;
    top         : 0;
    right       : 0;
    z-index     : 200;
    width       : 320px;
    height      : 100%;
}

div#middle {
    max-width   : 300px;
}

div#inner {
    overflow: auto;
    position: absolute;
    bottom:0;
    left:0;
    right:0;
    top:0;
}
Run Code Online (Sandbox Code Playgroud)