这里是a quick fiddle来解释我的问题,我的jQuery脚本:
var $headerHeight = $("header").height();
function $pushContentBelowHeader(){
$("#content").offset({top:$headerHeight});
};
$pushContentBelowHeader();
function $toggleAsideClass(){
var $presentationHeight = $("#presentation").outerHeight(true);
if ($(document).scrollTop() > $presentationHeight){
$('aside').addClass('fix-filters');
$('aside').offset({top: $headerHeight});
} else {
$('aside').removeClass('fix-filters');
}
};
$(document).scroll(function(){
$toggleAsideClass();
});
我希望首先放在一旁,然后将其卡在滚动条的标题下方。
我的切换类函数似乎在调试器中运行良好,标头的height值在检查器中也正确,但是... aside的style =“ top”不接受它,而是放置另一个随滚动而变化的值,我不知道为什么!
有什么想法吗?