最简单的方法,使滚动条滚动与jquery动画
simplest way to make a scrollbar scroll with jquery animation
我想制作一个div滚动条来滚动内容。有可能在几行代码中使用jquery吗?
http://jsfiddle.net/aHVpA/$(".motorcycles-wrapper").animate({scroll: '+=50'}, 1000, 'easeOutQuad');
下面是HTML代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script language="javascript">
$(".motorcycles-wrapper").animate({scroll: '+=50'}, 1000, 'easeOutQuad');
</script>
</head>
<style>
.motorcycles-wrapper {
height:170px;
background-color:#000;
width:200px;
overflow:scroll;
overflow-y:hidden;
}
</style>
<body>
<div class="views-field views-field-view motorcycles-wrapper"> <div class="field-content motorcycles-field"><div class="view view-ye-slide-show view-id-ye_slide_show view-display-id-block view-of-motorcycle view-dom-id-7f69086a9234de4a24878c146bdc52ac">
<div class="view-content">
<table class="views-view-grid cols-4">
<tbody>
<tr class="row-1 row-first row-last">
<td class="col-1 col-first">
<div class="views-field views-field-title"> <span class="field-content"><a href="/mysite/node/47">Falcone</a></span> </div>
<div class="views-field views-field-uc-product-image"> <div class="field-content"><a href="/mysite/node/47"><img typeof="foaf:Image" src="http://localhost/mysite/sites/default/files/styles/thumbnail/public/45c857_df2173694b2e1cc56e443a4103f02ede.jpg" width="100" height="100" alt=""></a></div> </div> </td>
<td class="col-2">
<div class="views-field views-field-title"> <span class="field-content"><a href="/mysite/node/45">V7 Special</a></span> </div>
<div class="views-field views-field-uc-product-image"> <div class="field-content"><a href="/mysite/node/45"><img typeof="foaf:Image" src="http://localhost/mysite/sites/default/files/styles/thumbnail/public/45c857_57fbe09be65ba8c265ee621184267e45.jpg" width="100" height="100" alt=""></a></div> </div> </td>
<td class="col-3"> <div class="views-field views-field-title"> <span class="field-content"><a href="/mysite/node/45">V7 Special</a></span> </div>
<div class="views-field views-field-uc-product-image"> <div class="field-content"><a href="/mysite/node/45"><img typeof="foaf:Image" src="http://localhost/mysite/sites/default/files/styles/thumbnail/public/45c857_57fbe09be65ba8c265ee621184267e45.jpg" width="100" height="100" alt=""></a></div> </div>
</td>
<td class="col-4 col-last"> <div class="views-field views-field-title"> <span class="field-content"><a href="/mysite/node/45">V7 Special</a></span> </div>
<div class="views-field views-field-uc-product-image"> <div class="field-content"><a href="/mysite/node/45"><img typeof="foaf:Image" src="http://localhost/mysite/sites/default/files/styles/thumbnail/public/45c857_57fbe09be65ba8c265ee621184267e45.jpg" width="100" height="100" alt=""></a></div> </div>
</td>
</tr>
</tbody>
</table>
</div>
</div></div> </div>
</body>
</html>
您需要使用scrollTop
或scrollLeft
取决于您想要滚动的方向。
$(".motorcycles-wrapper").animate({
scrollTop: "+=50"
}, 1000);
^这将向下滚动50。
$(".motorcycles-wrapper").animate({
scrollLeft: "+=50"
}, 1000);
^ this将向右滚动50
相关文章:
- Image赢得't隐藏在滚动jQuery上
- 无限滚动jquery不起作用
- 如何在水平滚动 Jquery 上实现延迟加载
- 在Firefox中快速滚动jQuery
- 触摸板滚动jQuery的问题
- 无限滚动jquery插件不起作用
- 如何仅在每次单击可滚动(jquery工具)中的导航按钮时加载图像,而不是一次加载所有图像
- 停止页面滚动 jquery
- 自动滚动 Jquery
- 动画滚动jquery不工作
- 导航锚点不'滚动jQuery时不能正确应用活动类
- 平滑滚动jquery插件在刷新时重置滚动起点.有办法解决这个问题吗
- 当用户滚动jquery时,停止ScrollTop功能
- 阻止自动向下滚动Jquery
- 水平滚动jQuery固定导航
- 平滑滚动jquery+修复导航错误
- 使用淡入淡出滚动jQuery效果的2列浮动画廊
- 无限滚动jQuery &Laravel 5分页
- 防止窗口滚动jquery
- 返回页首滚动jquery在chrome中不起作用.为什么?它在firefox中运行良好