【发布时间】:2011-09-11 14:49:02
【问题描述】:
我有一个按类型分组的嵌套购物类型列表(并且每个项目都有描述)。
我想要做的是让最后一个类型在列表中滚动,直到它滚动到列表顶部。
列表可以声明为
<div id="items">
<item-type>Type A</item-type>
<description>a</description>
<description>b</description>
<description>c</description>
<item-type>Type B</item-type>
<description>d</description>
<description>e</description>
<description>f</description>
<description>g</description>
<description>h</description>
</div>
我正在使用元素类型,以便可以在 CSS3 中使用 #items > item-type:last-of-type 来选择最后一个元素。
#items {
word-wrap: break-word;
overflow: auto;
height: 100%;
}
#items > * {
display: block;
}
#items > item-type:last-of-type {
position:absolute;
bottom: 100px;
}
所以现在唯一的一点是,我如何仅使用 CSS3(有效地)将 position: relative; top: 0 保持到 position: absolute; top: 0?
我正在使用FF4和HTML5,所以你可以全力以赴;旧版浏览器不支持此功能。另外,使用calc() 也可以。
有效的视图选项类似于:
______________________________________
Type A a Type B
a b e
b c f
c Type B g
d h
---------------------------------------
线条是可见区域,每列显示给定一定数量的数据(从左到右渐进)的显示方式
【问题讨论】:
-
如果我正确理解您的问题,我认为纯 CSS3 不可能。不过几行 jQuery 就可以工作了。
-
我不确定我是否理解最终结果应该是什么。你能详细说明一下吗?
-
您对问题的解释比较混乱,很难清楚地理解您想要实现的目标。我可以看到有一些滚动。但是有没有像ie这样的东西。冻结 Excel 中的列/行,这样它们就不会滚动,但其他一切都可以吗?但是最后的数据不能滚动出视口吗?
-
我不知道,但也许你可能追求的是
position:fixed? -
我已经更新了每个阶段的图表。由于第 2 列布局,
position:fixed不是很好;我想看到前面的项目(或尽可能多的),但总是想看到最后一个标题。
标签: html css scroll positioning