表格单元格内的可滚动DIV

我知道,我的答案是经典的,但我找不到合适的解决方案,不是在这里,也不是谷歌。我正在尝试使用表格创建布局。我希望
table#layout
是100%的屏幕(不是更多)和
#content-td
滚动。我的解决方案在FF / Chrome / Safari中运行良好,但在IE中有一些问题。如果
#content-td
height=100%
IE将设置高度等于桌面高度(这是错误的,因为我有
#header
)。当我从
#content-td
删除
height=100%
时IE将崩溃此销售。有没有javascript的解决方案来修复div的高度?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <style type="text/css">
            html, body, #layout {height:100%; width:100%; margin:0; padding:0; overflow:hidden;}
            #wrapper {overflow-y:scroll; position:relative; height:100%}
            #content {position:absolute;}
            /* highlight areas */
            #header {background-color:#BADBAD;}
            #sidebar {background-color:#DABDAB;}
            #wrapper {background-color:#CD5C5C; font-size:40px;}
        </style>
    </head>
    <body>
        <table id="layout" border="1" cellpadding="0" cellspacing="0">
            <tr height="1%">
                <td colspan="2" id="header">Header</td>
            </tr>
            <tr valign="top" height="100%">
                <td id="content-td" width="70%" height="100%">
                    <div id="wrapper">
                        <div id="content">
                            Here is long text I want to scroll down<br/>
                            Here is long text I want to scroll down<br/>
                            Here is long text I want to scroll down<br/>
                        </div>
                    </div>
                </td>
                <td id="sidebar" width="30%">Sidebar</td>
            </tr>
        </table>
    </body>
</html>
没有doctype它工作正常,但我想要一个有效的文档。这是测试页面。     
已邀请:
我认为你的第一个错误是想要使用表格进行布局。我相信你已经知道了它的含义,但如果你不知道,那么在网上寻找“没有桌子的布局”可能是值得的。 听起来你正在寻找的布局是主要内容正常滚动的布局,但侧面导航窗格总是在屏幕上的固定位置。对你的问题一个等价的解决方案,有趣的是在CSS中使用
position:fixed
来保持导航在视图中。例如,你可以制作一个主内容框和一个导航框,并使用这样的东西(在Firefox中测试):
body {margin-right:30%;}
#navigation {position:fixed; top:0; right:0; width:30%; height:100%; background:#fcc;}
如果这不是您想要的,那么提供一些示例站点或图表的链接。     

要回复问题请先登录注册