我希望通过css,动画制作边距,并在锚点到达页面顶部时按下UL列表。此外,这种代码类型有效,但它在响应中根本不起作用。
echo mv

mv

$(".testolino a").click(function(evn) {
evn.preventDefault();
$('html,body').scrollTo(this.hash, this.hash);
});
var aChildren = $(".testolino li").children();
var aArray = []; // create the empty aArray
for (var i = 0; i < aChildren.length; i++) {
var aChild = aChildren[i];
var ahref = $(aChild).attr('href');
aArray.push(ahref);
}
$(window).scroll(function() {
var windowPos = $(window).scrollTop();
var windowHeight = $(window).height();
var docHeight = $(document).height();
for (var i = 0; i < aArray.length; i++) {
var theID = aArray[i];
var theID1 = (i) * (-130) + 'px';
var divPos = $(theID).offset().top;
var divHeight = $(theID).height();
if (windowPos >= divPos && windowPos < (divPos + divHeight)) {
$("a[href='" + theID + "']").addClass("nav-active");
$(".listau").animate({
"margin-top": theID1
}, {
duration: 100
});
} else {
$("a[href='" + theID + "']").removeClass("nav-active");
}
}
if (windowPos + windowHeight == docHeight) {
if (!$(".testolino li:last-child a").hasClass("nav-active")) {
var navActiveCurrent = $(".nav-active").attr("href");
$("a[href='" + navActiveCurrent + "']").removeClass("nav-active");
$(".testolino li:last-child a").addClass("nav-active");
}
}
});
&#13;