Код, который создает точно такое же поведение, как 9gag.com:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- tags html, header, body, divs, anything -->
<div id="post-control-bar" class="spread-bar-wrap">
<div class="spread-bar" style="width:600px">
Facebook button, Twitter button, anything...
</div>
</div>
<script type="text/javascript">
window.onscroll = function()
{
if( window.XMLHttpRequest ) {
if (document.documentElement.scrollTop > 173 || self.pageYOffset > 173) {
$('post-control-bar').style.position = 'fixed';
$('post-control-bar').style.top = '0';
} else if (document.documentElement.scrollTop < 173 || self.pageYOffset < 173) {
$('post-control-bar').style.position = 'absolute';
$('post-control-bar').style.top = '';
}
}
}
</script>
<!-- content, footer, anything -->