У меня есть следующий код, который фиксирует положение меню в том месте, где оно будет прокручиваться вверху страницы.
$(function () {
var msie6 = $.browser == 'msie' && $.browser.version < 7;
if (!msie6) {
var top = $('.menu').offset().top - parseFloat($('.menu').css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
var y = $(this).scrollTop();
if (y >= top) {
$('.menu').addClass('fixed');
} else {
$('.menu').removeClass('fixed');
}
});
}
});
css
.container {
width:400px;
margin:auto;
}
.header {
background-color:#096;
height:150px;
}
.fixed {
position:fixed;
top:0px;
left:50%;
margin-left:50px;
}
.bodyContainer {
overflow:hidden;
}
.menu {
float:right;
width:150px;
height:250px;
background-color:#F00;
}
.bodyCopy {
float:left;
width:250px;
height:1000px;
}
.footer {
background-color:#096;
height:250px;
}
HTML
<div class="container">
<div class="header">
<p>Test Header</p>
</div>
<div class="bodyContainer">
<div class="menu">
<p>test</p>
</div>
<div class="bodyCopy">
<p>test</p>
</div>
</div>
<div class="footer">
<p>Test Footer</p>
</div>
What I now want to do is make it start scrolling again when the user reaches the bottom of the page (so that it does not cover the footer in the page).