0

我希望顶部栏在向下滚动时向下滑动,在向上滚动时向上滑动。

http://jsfiddle.net/aP7JY/8/

//when scroll down top-bar is fixed
$(function() {
    var top = $("#top-bar");
    $(window).scroll(function() {    
        var scroll = $(window).scrollTop();

        if (scroll >= 170) {
            top.show("fast").addClass("fixed");
        } else {
            top.removeClass("fixed");
        }
    });
});
4

2 回答 2

0

这可能会有所帮助。

   $(function() {
        var top = $("#top-bar");
        $(window).scroll(function() {    

            var scroll = $(window).scrollTop();
            $('#top-bar').offset({'top' : scroll});

        });
    });
于 2013-08-24T12:33:28.413 回答
0
function JSFX_FloatBottomLeft() {

var startX = 40, startY = 100;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id) {
    var el = d.getElementById ? d.getElementById(id) : d.all ? d.all[id] : d.layers[id];
    if (d.layers) el.style = el;
    el.sP = function(x, y) { this.style.left = x + "px"; this.style.top = y + "px"; };
    el.x = startX;
    el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
    el.y -= startY;
    return el;
}
window.stayBottomLeft = function() {
    var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;

    fblObj.y += (pY - startY - fblObj.y) / 8;
    fblObj.sP(fblObj.x, fblObj.y);
    setTimeout("stayBottomLeft()", 40);
};
fblObj = ml("dvPlumbCamp");
stayBottomLeft();}

它会停留在左下角,随着移动慢慢滑动

于 2013-08-24T12:23:21.760 回答