代码之家  ›  专栏  ›  技术社区  ›  Darryl Hein IrishChieftain

重新创建随页面滚动而移动的Apple Store摘要

  •  0
  • Darryl Hein IrishChieftain  · 技术社区  · 16 年前

    我想创建一个类似苹果在线商店的东西来显示你电脑的摘要和总数 as seen here . 我猜这是javascript,但如果可以用css来实现,那就更酷了。

    基本上我想要一个滚动的页面 position:fixed ,但我不希望在用户滚动到某个位置之前开始移动。

    我正在使用jquery,所以jquery插件也很完美。

    1 回复  |  直到 16 年前
        1
  •  3
  •   helios456    16 年前

    试试这样的

    var min = 10; //Set your own here
    $(window).scroll(function() { 
      var scrollTop = $(window).scrollTop()
      if(scrollTop > min)
        $('.divClass').css({  top: "0" });
      else
        $('.divClass').css({ top: (min - scrollTop) + "px" });
    });
    

    CSS

    .divClass
    {
      position:fixed,
      left: 500px /* or whatever */
    }