-6

我需要帮助找到像这样的jQuery js 固定左侧菜单。

固定位置滚动应取决于浏览器标题。

4

1 回答 1

2

在链接中查看答案

我在答案中准备了一个演示可能对您有帮助

你需要的主要是jQuery

$(function(){    // this is the shorthand for document.ready
  $(document).scroll(function(){    // this is the scroll event for the document

    scrolltop = $(document).scrollTop(); // by this we get the value of the scrolltop ie how much scroll has been don by user
    if(parseInt(scrolltop) >= 80)    // check if the scroll value is equal to the top of navigation
      { 
        $("#navbar").css({"position":"fixed","top":"0"});   // is yes then make the position fixed to top 0
      }
    else
    {
      $("#navbar").css({"position":"absolute","top":"80px"}); // if no then make the position to absolute and set it to 80
    }
  })

});
于 2012-10-08T15:23:25.020 回答