Edit:I found the problem: the tutorial used an addon ->
<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/jquery-throttle-debounce/1.1/jquery.ba-throttle-debounce.min.js"></script>
So yeah now it works ^-^, thanks for the help though :)
so its is a question that referes to this question: Change div css when user scrolls past it, using jQuery
I copied the jsfiddle code but it doesnt work :(
here is my page:
<html>
<head>
<title>Demo</title>
<style type="text/css">
body {
color:#000;
text-align:center;
font:700 60px/1'segoe ui', sans-serif;
}
div {
width:100%;
}
b {
opacity:.2;
}
.head {
height:250px;
line-height:250px;
background:#34495e;
}
.menu {
height:100px;
line-height:100px;
background:#1abc9c;
}
.main {
height:600px;
line-height:600px;
background:#ffffff;
}
.foot {
height:800px;
line-height:800px;
background:#34495e;
}
/* account for "Menu" being removed from doc flow... */
.dock .main, .stop .main {
padding-top:100px;
}
/* when "Head" is out of view... */
.dock .menu {
z-index:40;
position:fixed;
}
/* when "Main" is out of view... */
.stop .menu {
z-index:40;
position:absolute;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script type="text/javascript">
var elWrap = $(".wrap");
var elMenu = $(".menu");
var osMenu = elMenu.offset().top;
var osFoot = $(".foot").offset().top - elMenu.height();
$(window).scroll($.throttle(10, function () {
elMenu.css("top", 0);
var edge = $(window).scrollTop();
if (osMenu <= edge && osFoot > edge) {
elWrap.addClass("dock").removeClass("stop");
} else {
elWrap.removeClass("dock stop");
}
if (osFoot <= edge) {
elMenu.css("top", osFoot);
elWrap.removeClass("dock").addClass("stop");
}
}));
</script>
</head>
<body style="margin:0;">
<div class="wrap">
<div class="head"><b>Head</b>
</div>
<div class="menu"><b>Menu</b>
</div>
<div class="main"><b>Main</b>
</div>
<div class="foot"><b>Foot</b>
</div>
</div>
</body>
</html>