css - 静态标题+菜单,可滚动主体

标签 css layout header menu

这就是我想要完成的:

+--------screen-----------------------+
|       ______________________      |*|
|       |_static_header______|      |*|
|       |             |      |      |*|
|       | content     |menu  |      |*|
|       | scrollable  |static|      |*|
|       |             |      |      |*|
|       |             |      |      |*|
|       |             |      |      |*|
+-------------------------------------+

The content is of variable height, and the content scrollbar must be show in the page body (and not on it's on area). I managed to get the basic idea, but I'm having trouble to getting the content div in it's correct position when the scrollbar shows, and even if I set to always show the scrollbars, I can't use a fixed width because they differ from browser to browser.

<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>

在上面的代码中,内容因滚动条宽度而偏离,我怎样才能使它与页面的其余部分保持一致(即计算它的位置而不考虑滚动条宽度,即使它有滚动条宽度)?

最佳答案

如果我正确理解您的问题,这将是一个解决方案:http://jsfiddle.net/7pJS8/

关于css - 静态标题+菜单,可滚动主体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5196614/

相关文章:

javascript - 不工作 : jquery custom scrollbar please help?

android - Android 中的 AdMob 方向问题

wpf - 如何使工具栏中的项目填充 WPF 中的所有可用空间

soap - 将子元素添加到 Spring-WS 中的自定义 SOAP header

extjs - 如何在列标题中添加复选框? ext js

ios - UITableView 节标题滚动

html - 鼠标悬停在图片上时的效果

javascript - 如何根据浏览器设备添加/删除html元素和内容?

java - 条形码动画,移植到 ConstraintLayout

css - 使用 JavaFX 8 和 css 加载自定义字体