简体   繁体   English

滚动元素以水平查看

[英]Scroll element in to view horizontally

I have a list of divs which are floated left. 我有一个左浮动的div列表。 They are inside another div, which can be hovered over to move that inner block of divs left and right. 它们位于另一个div内,可以将其悬停以向左和向右移动该div内部块。 These inner divs or 'events' have class names which include a year. 这些内部div或“事件”的类名包括一年。

I also have a range slider at the bottom. 我还在底部有一个范围滑块。 The values of this slider are years. 此滑块的值是年。 When the range slider is changed I would like the first div which includes that year number to slide into view. 更改范围滑块后,我希望将包含该年份的第一格滑动到视图中。

See example here... http://thetally.efinancialnews.com/tallyassets/20years/index.html 在此处查看示例... http://thetally.efinancialnews.com/tallyassets/20years/index.html

Currently when you change the slider value the number changes accordingly, but I don't know how to slide everything so the related numbered div comes into view. 当前,当您更改滑块值时,数字也会相应更改,但是我不知道如何滑动所有内容,因此相关的带数字的div就会出现。 They are in a row of floated left divs so can't be absolutely positioned. 它们位于一排浮动的左div中,因此无法绝对定位。

In the example above the last event div has a class of 'year1998' so would be a good one to test the code on 在上面的示例中,最后一个事件div的类为“ year1998”,因此可以很好地测试以下代码

 var slider = $('#range-slider'),
 textbox = $('#range-no');

 slider.change(function() {
 var newValue = parseInt($(this).val());

 textbox.empty();
 textbox.append(newValue);

( I need something here which would say...
 $('.year'+newValue).comeintoviewplease();
... or something to that effect)
 });

Thanks in advance for any help 预先感谢您的任何帮助

检查一下,使用CSS过渡http://css3.bradshawenterprises.com/transitions/可以达到相同的效果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM