【发布时间】:2015-01-11 18:04:03
【问题描述】:
所以我有这个代码:
jQuery(document).ready(function($){
$( window ).scroll(function() {
var current_top = $(document).scrollTop();
var heights = window.innerHeight;
document.getElementById("sHome").style.height = heights * 0.8 + "px";
$('#sHome').css('top', (current_top*1));
});
});
更准确地说,我指的是:
$('#sHome').css('top', (current_top*1));
设置上边距等于滚动。
它工作正常,但是当我使用检查元素时,我有一个无限滚动,所以它就像 top: 7000px;
有没有办法限制这个值?
我找到了一个函数,Math.max(),但我不知道它在我的示例中是否有效。
干杯。
【问题讨论】: