jQuery 工具可滚动根元素相对定位而不是绝对定位
我注意到此页面上显示了可滚动项目的根元素。必须绝对定位。当尝试根据滚动的子元素的高度调整可滚动项目容器的大小时,这会导致问题。
http://flowplayer.org/tools/demos/scrollable/
我只是改变了位置:绝对定位:相对,这样容器就会尊重孩子的高度,效果很好。它在所有浏览器中滚动良好。我在这里错过了什么吗?为什么一定要绝对定位呢?它相对于我工作的容器的位置。只是寻找一些意见/想法。
谢谢
I noticed on this page that it says the root element for scrollable items. Must be absolutely positioned. This is causing issues when trying to resize the scrollable items container according to the height of the child elements that scroll.
http://flowplayer.org/tools/demos/scrollable/
I simply changed position:absolute to position:relative so the container will respect the child height and that worked fine. It scrolls in all browsers fine. Am i missing something here? Why is it mandatory to have it absolutely positioned? Its positioned relative to the container its in which works for me. Just looking for some input/thoughts.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际的要求只是定位以便滚动/分页工作。滚动运动是通过设置
left
样式属性的动画来完成的。如果没有定位,无论相对
还是绝对
,负向左偏移都会被忽略。因此,当您更改为
position:relative
时,它并没有中断。如果您完全删除了position
声明,那么它就会中断并且无法滚动。The actual requirement is just to be positioned in order for the scrolling/paging to work. The scrolling motion is done by animating the
left
style property. Without positioning, regardless whetherrelative
orabsolute
, the negative left offset would have been ignored.So it didn't break when you've changed to the
position: relative
. If you've removed theposition
declaration altogether, only then it would break and fail to scroll.