【发布时间】:2011-07-08 23:18:59
【问题描述】:
这就是我想要完成的:
+--------屏幕-----------+ | ______________________ |*| | |_static_header______| |*| | | | | |*| | |内容 |菜单 | |*| | |可滚动|静态| |*| | | | | |*| | | | | |*| | | | | |*| +--------------------------------------------------+内容高度可变,内容滚动条必须显示在页面正文中(而不是显示在页面上)。 我设法得到了基本的想法,但是当滚动条显示时,我无法让内容 div 处于正确的位置,即使我设置为始终显示滚动条,我也不能使用固定宽度,因为它们不同从浏览器到浏览器。
<div style="position:absolute; background-color:Transparent; left:0px; right:0px; height:100px; z-index:2;">
<div style="background-color:Silver; width:1000px; height:100px; margin:0 auto;">
Header
</div>
</div>
<!-- Fixed div acting as the body "page" so the scrollbar shows as the page's -->
<div style="position:absolute; left:0px; top:0px; bottom:0px; right:0px; overflow-y:auto; padding-top:100px; z-index:1;">
<div style="position:relative; width:800px; height:100%; margin:0 auto; padding-right:200px;">
<div style="background-color:Orange; width:100%; height:900px;">
Content
</div>
</div>
</div>
<div style="position:absolute; left:50%; right:0px; padding-top:100px; z-index:0;">
<div style="width:500px; float:left;">
<div style="background-color:Green; float:right; width:200px; ">
Menu
</div>
</div>
</div>
在上面的代码中,内容被滚动条宽度所关闭,我怎样才能正确处理页面的其余部分(即,在不考虑滚动条宽度的情况下计算它的位置,即使它有一个)?
【问题讨论】:
-
+1 ascii 图形。并且很高兴在 SO 上看到新用户提出的格式良好的问题。
-
这是固定宽度还是标题应该跨越整个视口?
-
整个“正文”(标题、内容+下面的菜单)的宽度是固定的。当我没有设置固定宽度时,我之前在使用非常宽的显示器时遇到问题......
-
理解您的 HTML 非常困难,我建议您以后添加适当的类名/ID 并使用样式表。