扫码关注官方订阅号
先上地址:https://jsfiddle.net/4q6LLk4z/
我截图了, 意思是如果红色盒子到了终点的话, 让红色盒子的底部 回到灰色盒子的底部。
PS: 红色的高度是不固定的。 我想了半天都不知道怎么算。
求大神在我原有的代码修改下。
认证0级讲师
直接上代码:
var h = $('.box').height() - $('.container').height(); if(h>0){ $('.box').animate({ top:-h+'px' },1000); }
你是要回弹效果么?
var box_h = $('.box').height(); var con_h = $('.container').height(); $('.box').animate({ top:-box_h },1000,function(){ $('.box').animate({ top:"+="+con_h }) });
https://jsfiddle.net/jamesfan...
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
直接上代码:
更新答案
你是要回弹效果么?
https://jsfiddle.net/jamesfan...