簡體   English   中英

位置:固定不指代父母的相對左側位置

[英]position: fixed not referring parent relative left position

我有一個例子:向下滾動時,滾動條到達RHS面板標題時,RHS面板處於浮動狀態。

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

但是在向下滾動時,RHS面板跳至屏幕外; 我不為什么固定的位置不引用父相對位置。 它指的是身體的左側位置。

在低於css后更改其工作正常

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

如果有人知道更好的解決方案,請告訴我。

由於您詢問了為什么會發生這種情況,因此請參閱position : fixed的定義position : fixed CSS規范中已 position : fixed

對於固定位置的框,包含塊由視口建立。

或者,正如另一個網站所說,

the parent element is always the browser window
var wHeight = $(window).height();
$('.right-panel').css("height",wHeight-80);
if ( scrollY > bodyY && isfixed ) {
 $floatingbox.stop().css({
position: 'fixed',
    // left: wLeft,
top: 10

刪除!isfixed並使其固定

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM