我有一个奇怪的问题,我有一个div
_inputHelper // it has fixed height ( 200px )
其中包含非常长的<ul>
列表(大约200个元素),我想使用jQuery滚动到<li>
列表中的某些列表,但是问题是,当我以这种方式滚动整个列表时:
$( _inputHelper.find('ul') ).animate( { top : -1 * ( $(_this).position().top - $(_this).height() ) } , 200);
_this is a LI element I would like to scroll to
在适当的位置向下滚动,但我无法使用鼠标滚动列表,以下是更精确的打印屏幕:
我认为我可能以错误的方式滚动,但我也尝试了scrollTop / margin-top,但仍然无法正常工作。
一些测试:http : //jsfiddle.net/uk5xqfry/3/
有什么帮助吗?
根据您需要使用的小提琴scrollTop
,尝试以下操作:
$('.input-helper').animate({
scrollTop : $("#test").position().top,
}, 200);
检查演示小提琴
在代码中,您只是移动ul
元素,然后移出父视图;现在,您正在更改父级的滚动。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句