0
点赞
收藏
分享

微信扫一扫

jquery插件:任意位置浮动固定层(09-11-05更新插件)


见第一个附件
存在问题:当放大或者缩小窗口时候,浮动不会变化。


只能浮动:

<div class="float" id="float">
我是个腼腆羞涩的浮动层...
</div>

$.fn.smartFloat = function() {
    var position = function(element) {
        var top = element.position().top, pos = element.css("position");
        $(window).scroll(function() {
            var scrolls = $(this).scrollTop();
            if (scrolls > top) {
                if (window.XMLHttpRequest) {
                    element.css({
                        position: "fixed",
                        top: 0
                    });    
                } else {
                    element.css({
                        top: scrolls
                    });    
                }
            }else {
                element.css({
                    position: "absolute",
                    top: top
                });    
            }
        });
    };
    return $(this).each(function() {
        position($(this));                         
    });
};

//绑定
$("#float").smartFloat();

举报

相关推荐

jQuery05插件

jQuery05(插件)

jQuery05(插件)

jQuery05(插件)

jQuery——插件

jQuery插件

JQuery插件

0 条评论