views:

45

answers:

2
+1  A: 

I guess the "best practice" for accomplishing a task like this is to use dynamically changing css position from absolute to fixed and vice versa. A basic example could look like:

$(function(){
   var $box    = $('.box'),
       offset  = $box.offset(),
       doc_h   = $(document).height();

    $(window).scroll(function(){
        if($(window).scrollTop() > offset.top) {
            if(!$box.hasClass('fix'))
                $box.toggleClass('normal fix');
        }
        else{
            if(!$box.hasClass('normal'))
                $box.toggleClass('normal fix');
        }
    });
});​

Example in action: http://www.jsfiddle.net/YjC6y/14/

jAndy
I guess this isn't the OP wants
Ninja Dude
I'll try this one out - however I had hoped on a solution that was more like the code i have now, but with the box following the bottom instead of the top.
MadsK
A: 
$(function() {
  var top = 50;
  $(window).scroll(function() {
    $('#box').stop().animate({ top: $(window).scrollTop() + top}, 1000);
  });
});

Try the example : http://jsbin.com/omiyi3

Ninja Dude
I'm not really seeing the difference between the one i've made and yours. The box still follows the top thus making the bottom unavailable on smaller screens.
MadsK