Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Sticky Footer</title>
<style>
  #wrapper { border:1px solid #333; padding:10px;}
  #footer { background:#333; color:#fff; width:98%}
</style>
</head>
    <body>
        <div id="wrapper">
            <div id="header"> Header </div>
            <div id="content-wide"> Content </div>
            <div id="footer">Footer</div>
        </div>
    </body>
</html>
 
//footer stick
$(window).bind("load", function() {
    var footerHeight = 0,
        footerTop = 0,
        $footer = $("#footer");
    positionFooter();
    function positionFooter() {
        footerHeight = $footer.outerHeight();
        footerTop = ($(window).scrollTop() + $(window).height() - footerHeight) + "px";
        if (($(document.body).height() + footerHeight) < $(window).height()) {
            $footer.css({
                position: "absolute",
                top: footerTop
            });
        } else {
            $footer.css({
                position: "static"
            });
        }
    }
    $(window).scroll(positionFooter).resize(positionFooter);
});
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers