0

dom我有一个插件,我在其中提供了一个简单的 div 容器,该插件通过 javascript 在容器内创建各种元素。插件创建的基本结构是这样的:

Wrapper Div (Position:Relative)
   - Left Container (Position: Absolute)
        - Left Top sub-container (Position: Absolute)
   - Right Container (Position: Relative)
        - Right Top sub-container (Position: Absolute)
        - Right Sub-Container frame with absolute items (Position: Relative)

这是我为插件创建的完全相同的结构创建的小提琴:http: //jsfiddle.net/FsYt8/

我在这里面临的问题是,当内容溢出时,可以用鼠标滚轮滚动内容(如小提琴)。但是,当我向下滚动时,我希望上面两个左上角和右上角的子容器(红色/蓝色条)颜色保持在顶部,而不是随着内容向下滚动。

该插件在 div 内创建 dom 元素container-right-frame并将元素定位为绝对(然后根据container-right的顶部/左侧定位)。如何实现上述两个条的固定定位?

4

2 回答 2

0

您可以将红色和蓝色 DIV 固定并将它们浮动到左侧。右侧 DIV 的左边距将调整 DIV 的 x 轴位置,如下所示:

.frame {width:924px;height:300px;position:relative;overflow-x:hidden;}
.axis-left {float:left;width:303px;height:34px;position:fixed;background-color:blue;z-index:2;}
.axis-right {float:left;margin-left:305px;width:303px;height:34px;position:fixed;background-color:red;z-index:2;}
.container-left {height:340px;width:303px;left:0px;position:absolute;background-color:green;z-index:1;overflow:hidden;}
.container-right {height:340px;left:304px;position:relative;overflow:hidden;}
.container-right-frame{
    position:relative;top:34px;background-color:yellow;z-index:1;width:615px;
}
于 2013-03-11T12:52:29.577 回答
0

使标题固定并相应地定位它们:

http://jsfiddle.net/QYCra/

将列的初始高度向下移动,以便它们从标题下开始:

.frame {width:924px;height:300px;position:relative;overflow-x:hidden;}
.axis-left {width:303px;height:34px;position:fixed; top:0; background-color:blue;z-index:2;}
.axis-right {width:615px;height:34px;position:fixed; top:0; left:310px; background-color:red;z-index:2;}
.container-left {height:340px;width:303px;top:30px; left:0px;position:absolute;background-color:green;z-index:1;overflow:hidden;}
.container-right {height:340px;width:615px;top:30px; left:304px;position:relative;overflow:hidden;background-color:yellow;z-index:1;}
于 2013-03-11T12:38:00.327 回答