代码由三部分构成,分别是CSS+DIV+JS,兼容IE6浏览器,其他的应该都没问题,我暂时没测,目测很好用。推荐!『演示见下方』
 

CSS:

.demo {
    height: 1500px;
}
.float {
    background-color: #FFFEE0;
    border: 1px solid #FFECB0;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    padding: 10px;
    position: absolute;
	left:0;
    top: 80px;
    width: 100%;
}

HTML:

<div class="demo">
</div>       
<div class="float" id="float">
    我是个腼腆羞涩的浮动层...
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script>
$.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();
</script>

在线演示

float_demo0619.rar