C# 使用velocity.js自动滚动div而不移动整个页面
我想使一个自动滚动在一个div,但我的代码滚动整个页面。我怎样才能使它只在div中滚动 代码:C# 使用velocity.js自动滚动div而不移动整个页面,c#,jquery,autoscroll,velocity.js,C#,Jquery,Autoscroll,Velocity.js,我想使一个自动滚动在一个div,但我的代码滚动整个页面。我怎样才能使它只在div中滚动 代码: <div class="banner"> div class="logo"></div> </div> <div id="container"> <div class="tile"></div> . . . </div> 在JQuery中: var scrollWidth
<div class="banner">
div class="logo"></div>
</div>
<div id="container">
<div class="tile"></div>
.
.
.
</div>
在JQuery中:
var scrollWidth = $("#container").width();
var scrollHeight = $("#container").height();
$("#container").velocity("scroll", {
axis: "x",
duration: 10000,
offset: scrollWidth
})
.velocity("scroll", {
axis: "y",
duration: 10000,
offset: scrollHeight
});
我上面提供的代码将与.banner一起滚动,但我想确定自动滚动#container div时的位置。我正在使用velocity.js进行自动滚动。如果在
#container
内滚动,则必须在velocity动画中提供container
属性,请选中
另一个解决方案是将横幅的位置设置为固定而不是绝对
var scrollWidth = $("#container").width();
var scrollHeight = $("#container").height();
$("#container").velocity("scroll", {
axis: "x",
duration: 10000,
offset: scrollWidth
})
.velocity("scroll", {
axis: "y",
duration: 10000,
offset: scrollHeight
});