實現側邊導航欄的懸浮設置


首先看效果圖:

最開始鼠標沒有滾動的時候:

 

 當鼠標滾動下拉到一定高度的時候:

 

 側邊的懸浮框會一直懸浮在最左邊,實現導航的懸浮。

通過js代碼實現:

 

 js代碼:

var n_t1 = $('body').height() * 0.12;
            if(scrTop < n_t1){
              $('.content2_left').css("position","absolute")
              $('.content2_left').css("left","0px")
              $('.content2_left').css("top","0px")
            }else{
                $('.content2_left').show()
                // $('.content2_left').css("background-color","red")
                $('.content2_left').css("position","fixed")
                $('.content2_left').css("left","10%")
                $('.content2_left').css("top","5%")

            }

  

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM