javascript - 位置 : fixed not referring parent relative left position

标签 javascript jquery html css

我做过一个例子:向下滚动时,当滚动条到达 RHS 面板标题时,RHS 面板 float 。

http://www.elankeeran.com/test/RHSpanel.htm

但是向下滚动 RHS 面板时会跳转到屏幕外;我不明白为什么 position fixed 不是指父相对位置。它指的是 body 的左侧位置。

在 css 下更改后它工作正常

#floating-box{position: absolute;width:100%;width:960px; margin:0 auto;}

如果有人知道更好的解决方案,请告诉我。

最佳答案

既然你问过为什么会发生这种情况,请参阅 the CSS specposition : fixed 的定义, 值得注意的是

for a fixed positioned box, the containing block is established by the viewport.

或者,作为 another site把它,

the parent element is always the browser window

关于javascript - 位置 : fixed not referring parent relative left position,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5530578/

相关文章:

javascript - 尝试使用 AJAX 和 PHP

javascript - HTML 密码验证

javascript - 在类之间切换会使动画无法继续,只是跳到结束

javascript - 选择/选中另一个时禁用选择/复选框

javascript - Onclick JavaScript 在 IE 中无法正常工作

javascript - 更改 Fullcalendar React 组件的语言

javascript - 在 Javascript 中根据另一个输入的值更改输入值,反之亦然

javascript - WordPress 将 javascript 添加到 native WordPress 帖子/页面编辑器

javascript - 了解 setInterval 中剩余的时间并将其应用于计时器的暂停和恢复

javascript - Angularjs 使用 ng-init 为 ng-model 赋值