【问题标题】:Fixed css menu depending on browser header修复了取决于浏览器标题的 CSS 菜单
【发布时间】:2012-09-28 20:55:30
【问题描述】:

我需要帮助找到 jQuery js 固定左侧菜单 like this

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

【问题讨论】:

  • 您能否更清楚地解释您需要什么,并描述您已经尝试过的内容?
  • 请告诉我们您的尝试,我们可以为您提供更好的帮助。
  • 看看他们的代码。我不到一分钟就找到了。
  • 我需要右 div 表在滚动时保持固定,但它需要在浏览器标题触摸侧面菜单顶部后处于活动状态,如访问:tringme.com/howitworks.html。我只需要 js 演示 :)

标签: javascript html css css-position


【解决方案1】:

link中查看答案

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

你需要的主要是 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
    }
  })

});

【讨论】:

猜你喜欢
  • 2014-08-02
  • 1970-01-01
  • 2012-04-02
  • 2012-09-26
  • 1970-01-01
  • 2015-01-03
  • 2014-06-04
  • 2018-08-21
  • 1970-01-01
相关资源
最近更新 更多