我已经制作了一个带有 div 的 div,我希望内部 div 在外部 div 内上下滚动页面上上下浮动。我以某种方式设法使其限制不超出外部 div 表单,但是当它到达底部时,它会下降到页面底部。请帮助我,这是我的代码 css
CSS
#comment {
position: absolute;
/* just used to show how to include the margin in the effect */
}
HTML
<!--the outer div in which i have whole content -->
<div class="content">
<!--the floating div, remains well inside form top but moves down outside div from bottom -->
<div class="ftwrapper" id="comment">
</div><!--fb/twitter ends-->
</div>
jQuery
$(function () {
var msie6 = $.browser == 'msie' && $.browser.version < 7;
if (!msie6) {
var top = $('#comment').offset().top - parseFloat($('#comment').css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('#comment').addClass('fixed');
} else {
// otherwise remove it
$('#comment').removeClass('fixed');
}
});
}
});