jquery - jQuery 中的动画标题

标签 jquery css image animation slide

我找到了这个很酷的 jQuery 脚本来为标题设置动画:http://www.devirtuoso.com/2009/07/how-to-build-an-animated-header-in-jquery .但是我想稍微改变一下,但不幸的是我的脚本技能有限。

我想要做的是:当动画到达图像的末尾时,我希望它再次向上滚动,而不是像教程中那样重新开始。所以,基本上图像会不断地上下移动。

有人知道脚本会是什么样子吗?

问候

最佳答案

尝试将 scrollBg() 函数更改为:

function scrollBg(){

//Go to next pixel row.
current -= step;

//If at the end of the image, then go to the top.
if (current == restartPosition){
    step = -1;
} else if (current == 0) {
    step = 1;
}

//Set the CSS of the header.
$('#header').css("background-position","0 "+current+"px");
}

这是一个非常基本的工作示例(仅用于演示目的 - 使用上面的代码):http://jsfiddle.net/lukemartin/u2XJ8/

它所做的只是在到达循环的任一端时切换步长值。

关于jquery - jQuery 中的动画标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4987624/

相关文章:

jquery - bootstrap 可折叠导航栏开始打开

html - 如何获得响应式汉堡菜单而不下推内容

css - 可以创建调色板以便于自定义 [CSS]

html - 在 JSP 中加载 img

java - 我在尝试加载 png 图像时收到 null 返回错误

java - 代号一 : Why am I getting "/by zero" when trying to scale an image

javascript - 如何循环替换文本中的所有文本?

javascript - 将 JavaScript 数据发布到 Rails 的最佳方式

javascript - 如何获取 jQuery 选择的 drodpown 列表框的 onclick 事件?

php - 如何在一个循环中使行溢出