jQuery jStick demo

This is a very basic example of what you can do with the jQuery plugin "jStick". More info : https://github.com/nicooprat/jStick

by bizamajig

HTML

<script src="https://github.com/nicooprat/jStick/raw/master/js/jquery.jstick.js"></script>
<!DOCTYPE HTML>
<html>
    <head>
        <title>jStick2Top</title>
        <link rel="stylesheet" href="css/reset.css" />
        <link rel="stylesheet" href="css/style.css" />
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript" src="js/jquery.jstick.js"></script>
    </head>
    <body>
        
        <div id="top"></div>
        <div id="header">#header</div>
        <div id="nav">#nav</div>
        <div id="content">#content</div>
        <div id="footer">#footer</div>
        
    </body>
</html>

CSS

/* http://meyerweb.com/eric/tools/css/reset/ 
v2.0 | 20110126
License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}
/* Variables
-------------------- */
/* Mixins
-------------------- */
/* Containers Styles
-------------------- */
/* Text Styles
-------------------- */
/* Common Classes
-------------------- */
.clear {
    display: block;
    width: 100%;
    height: 0;
    visibility: hidden;
    clear: both;
}
.left {
    float: left !important;
}
.right {
    float: right !important;
}
/* Pages Styles
-------------------- */
#top {
    height: 20px;
    background: #C00;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 3;
}

#header {
    height: 150px;
    padding: 150px 0 0 0;
    background: url(img/stripes.png);
    border-top: 1px solid #333;
}

#nav {
    height: 50px;
    background: black;
    z-index: 2;
}

#nav.stuck {
    opacity: .5;
}

#content {
    height: 550px;
    padding: 150px 0 0 0;
    background: url(img/grain.png);
}

#footer {
...

JavaScript

$(document).ready(function() {

    $('#nav').jStick({
        opacity: .5,
        shadow: '0 3px 3px #666',
        offset: $('#top').height(),
        limit: $('#footer').offset().top,
        onStick: function() {
            console.log('stuck');
        },
        onUnstick: function() {
            console.log('unstuck');
        },
        onLimitReached: function() {
            console.log('limit reached');
        }
    });

});