gpt4 book ai didi

jquery - 如何阻止 JQuery Animate 函数移动整个页面

转载 作者:行者123 更新时间:2023-11-28 13:11:14 25 4
gpt4 key购买 nike

我无法让动画函数只移动指定的 DIV。相反,它会移动整个页面。如果您单击下面链接上的“RSVP”,您可以看到我在说什么。我试过将它切换为仅调用某些 ID(即 .wrap 与 #header),但它没有做任何事情。你如何让它只动画标题而不滚动其他任何东西?

这是我的代码。还有更多内容,但我只包含了具有淡入淡出/滚动属性的 JQuery:

  $.ajax({
type: "POST",
url: "http://mktietheknot.com/wp-content/themes/Retro/rsvp-process.php",
data: dataString,
dataType: "json",
success: function(data) {
if ( data.status == 'pass' ) {
$('#rsvp-form').fadeOut(function(){

$('#rsvp-form').html('<div class="rsvp-received">' +data.response+ '</div>').fadeIn(1000);

});

myTimer = $.timer(2500,function(){

$('#rsvp .rsvp-link').click();

});

}
else {

$('#rsvp-form').append('<div class="error">' +data.response+ '</div>');
$('#rsvp .submit').fadeIn('500');
console.debug(data);

}
}
});

return false;

});
});

$('#nav-rsvp a').unbind();
$('#nav-rsvp a, .rsvp-link').click(function(){
if ( $('.wrap').hasClass('open') ) {
$('.wrap').animate({
top: '-=115'
}, 750, 'easeInOutCubic');
$('.wrap').removeClass('open');
}
else {
$('.wrap').animate({
top: '+=115'
}, 750, 'easeInOutCubic');
$('.wrap').addClass('open');
}
return false;
});

})(jQuery);

这是他对 CSS 的赞美:

/* === Header Section === */
#header {
background:url(wp-content/themes/Retro/images/structure/body_bg.png) repeat-x scroll center bottom transparent;
padding: 0 0 13px;
position:fixed;
width: 100%;
z-index: 100;
}
#header .section_inn {
padding-top: 0;
background:url(http://mktietheknot.com/wp-content/themes/Retro/images/structure/body_bg_brown.png) repeat-x;
width: 100%;
height: 130px;
z-index: 1000;
}
#header .wrap {
background: none repeat scroll 0 0 transparent;
width: auto;
top:-115px;
}

谢谢大家!

最佳答案

尝试为#header 上的顶部样式设置动画。它需要被动画化以

#header {top:115px}

关于jquery - 如何阻止 JQuery Animate 函数移动整个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15505423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com