I am having difficulty resolving a jquery issue,
my code works in a fiddle but when i add it into my document is wont work.
please see link
Any help would be great !!!!
http://paulobriendesign.co.uk/chartego/test.html (not working) http://jsfiddle.net/7Gacp/ (working)
my html
<html>
<head>
<title>Page Title</title>
</head>
<style>
#profile-container {
padding-top:52px;
/* Red bar height */
margin:0;
/* Clear default browser margin */
}
#profile-container.fixed {
padding-top:82px;
/* Red bar height + yellow bar height */
}
#profile-container {
height:2000px;
}
#fixed-header {
width:100%;
position:fixed;
height:50px;
border:1px solid black;
top:0px;
background-color:red;
}
.container {
height:300px;
width:100%;
background-color:blue;
}
.sticky-header {
width:700px;
height:50px;
background:orange;
}
.sticky-header {
height:30px;
width:100%;
background:yellow;
}
.fixed .sticky-header {
position: fixed;
top:52px;
margin-bottom:52px;
}
.img {
width:200px;
height:200px;
border:1px solid grey;
float:left;
}
</style>
<script>
var offset = $(".sticky-header").offset();
var sticky = document.getElementById("sticky-header")
var additionalPixels = 50;
$(window).scroll(function () {
if ($(window).scrollTop() > offset.top - additionalPixels) {
$('#profile-container').addClass('fixed');
} else {
$('#profile-container').removeClass('fixed');
}
});
</script>
<body>
<div id="profile-container">
<div id="fixed-header"></div>
<div class="container"></div>
<div class="sticky-header">This needs to be fixed when hits top of screen</div>
<div class="img">needs to be smooth</div>
<div class="img"></div>
<div class="img"></div>
</div>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
</body>
</html>