簡體   English   中英

滾動后如何將Div更改為“ Fixed”

[英]How To Change Div To “Fixed” After Scroll

在Academicearth的About頁面上,它們的右側有一個<aside>標記,一旦您開始滾動,該標記就會fixed

http://academicearth.org/about/

怎么做?

<aside>標記fixed ,它還向右移一點,以適應滾動顯示的內容。

使用滾動事件。

$(document).scroll(function(e)
{ 
    //grab position of scrollbar
    position=$(document).scrollTop();
    //when position match a height
    if(position==desired_height)
    {
      //grab element 
      $('ele').css('position','fixed');
    }
}

暫無
暫無

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

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