[英]jQuery scrollTop jumps to top of screen
When I load the page, the div is at the top of the screen, but when I start the scroll, it jumps to where it is supposed to be. 当我加载页面时,div位于屏幕的顶部,但是当我开始滚动时,它会跳转到应有的位置。
Check out the website here: calretirement.com/classes-test.php 在此处查看网站:calretirement.com/classes-test.php
CSS: CSS:
.register{position:fixed !important; bottom:120px !important; width: 340.453px;
margin-top: 29px;
}
#stickyForm2015 {-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
jQuery: jQuery的:
<script>
$(window).scroll(function(){
if
($(window).scrollTop() > 670){
$("#stickyForm2015").addClass("register");
}
else
{
$("#stickyForm2015").removeClass("register");
updateSliderMargin();
}
});
</script>
<script>
$(window).on("scroll", function(){
if
($(window).scrollTop() > 2500){
$("#stickyForm2015").removeClass("register");
updateSliderMargin();
}
});
</script>
Open to suggestions!! 开放的建议! Need help!
需要帮忙!
If you want to animate scroll with jquery you can just do: 如果要使用jquery动画滚动,可以执行以下操作:
$('html, body').animate({scrollTop: '0'}, 400);
If you want to animate with css you need to animate from something to something, your classes don't appear to be doing that. 如果要使用css进行动画处理,则需要从某物到某物进行动画处理,您的类似乎没有这样做。
.original-class{
position: relative;
top: 500px;
transition: top .4s ease-in-out; //only necessary if you plan on animating back
}
.animate-original-class{
top: 0;
transition: top .4s ease-in-out;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.