滚动到水平 div 中的元素 [英] scroll to element in horizontal div

查看:24
本文介绍了滚动到水平 div 中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个水平 div:

我需要通过 JavaScript 按钮滚动到此 div 中的特定元素(点击 div 后必须滚动到该元素).我该怎么做?

<div class="item frame-item"><img src="1.jpg">

<div class="item frame-item"><img src="2.jpg">

........

解决方案

$.scrollTo 是你的朋友:

$(container).scrollTo(target)

I have a horizontal div:

i need to scroll to the specific element in this div via JavaScript button (after the click div must be scrolled to that element). How can I do this?

<div class="group" id="frames">
<div class="item frames-item">
<img src="1.jpg">
</div>
<div class="item frames-item">    
<img src="2.jpg">
</div>
....
....
</div>

解决方案

$.scrollTo is your friend:

$(container).scrollTo(target)

这篇关于滚动到水平 div 中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆