【问题标题】:jQuery Floating Menu Does not Work in ChromejQuery 浮动菜单在 Chrome 中不起作用
【发布时间】:2011-04-05 21:41:28
【问题描述】:

我正在为 jQuery 开发一个浮动菜单插件,它让我发疯,因为它在其他浏览器中运行良好,但在 Chrome 中它只是坐在那里,而不是在用户向上或向下滚动时滚动页面:

                // Cache :)
            var fblb_cont = $("#fblb_cont");
            var fblb_main = $("#fblb_cont .fblb_main"); 
            var fblb_pos = $('#fblb_cont').position().top;
            var float_easing = "easeOutQuint";

            // When the user scrolls
            $(window).scroll(function () { 


                // Float our bar to correct page location
                // Figure out how much to scroll
                var scroll_factor = $(document).scrollTop();

                // Create our new scrollTo position             
                var newPos = ( fblb_pos + scroll_factor );

                // Check if the window height is within bounds
                if( $(window).height() < $("#fblb_cont").height()+$("#fblb_cont .fblb_main").height() ){

                    // Adjust where needed
                    fblb_cont.css("top", fblb_pos);

                } else {

                    // Otherwise animate our scroll to the new position
                    $("#fblb_cont").stop().animate({top: newPos}, defaults.float_speed, float_easing);

                } // End if



            }); // End on scroll

【问题讨论】:

    标签: jquery google-chrome floating


    【解决方案1】:

    试试这个:

    $("#fblb_cont").stop().animate({top: newPos + 'px'},
                              defaults.float_speed, float_easing);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-19
      • 2011-08-05
      相关资源
      最近更新 更多