This is a jQuery extension I wrote to generically fix HTML elements to a page when the user scrolls past them. To see what I mean, scroll down on this page. Note that this plugin is now unmaintained. If you want this functionality, it would probably be better to use the more popular ScrollToFixed plugin.
I noticed that there was no extension that did this smoothly and for any element on a page, so I decided to write it myself. There are several test cases available. I've tested this in Chrome, Firefox, IE7, IE8, IE9, and Safari. If any of the test cases don't work in a browser you think they should work in, please report a bug. For usage details, view the README on Github.