我在网站标题中有图片作为背景。现在,当页面加载时,我想从左向右缓慢移动(大约100像素),然后停止。有没有不太复杂的方法来做到这一点?css背景图片移动
3
A
回答
2
jQuery将允许你轻松地做到这一点。
$("#theImage").animate({
left: "+=100px",
}, "slow");
2
您应该检查以确保它只在首页加载时动画,而不是从内部站点链接加载。我喜欢使用jquery这种事情。
// animate on first load only
if (document.referrer == null || document.referrer.indexOf(window.location.hostname) < 0) {
$("#logo").animate({
marginLeft: "100px",
easing: 'swing'
}, 3000); // adjust your duration here (milliseconds)
} else {
// internal site link set the proper position
$("#logo").css({ marginLeft: "100px"});
}
2
谢谢,Rap和ghoppe!这是一个有用的提示。其实我是移动的背景图像,而不是它的容器,所以我第一次设置其CSS中的位置:
.top-back-image { background-position: -100px 0px; }
,然后使用jQuery:
$(".top-back-image").animate({
backgroundPosition: "0px 0px",
easing: 'swing'
}, 3000);
1
的家伙了,在LaunchList有一个移动背景。通过他们的CSS浏览,这是我发现的。也许它会有一些帮助。
#clouds {
width: 100%;
height: 650px;
top: 200px;
display: block;
position: fixed;
background: url(../art/cloud.png) 500px 0 repeat-x;
-webkit-animation-name: move;
-webkit-animation-duration: 400s;
-webkit-animation-iteration-count: infinite;
z-index: 2;
}
请注意,这将仅针对webkit浏览器显示。
相关问题
- 1. CSS滚动背景图片
- 2. 移动背景图片
- 3. CSS移动背景图像
- 4. CSS背景图像移动
- 5. 背景CSS图片
- 6. CSS背景图片
- 7. CSS背景图片和默认背景?
- 8. 制作CSS背景图片滚动
- 9. 的CSS - 动画背景图片 - 带环
- 10. jQuery的CSS动画,背景图片
- 11. 移动背景图片放大
- 12. 用窗口移动背景图片
- 13. 使用移动背景图片:目标
- 14. 右键移动背景图片
- 15. 背景图片在移动设备上
- 16. 背景中的可移动大图片
- 17. 在循环中移动背景图片
- 18. 上下移动背景图片
- 19. CSS - 旋转背景图片
- 20. Jekyll CSS背景图片
- 21. CSS中的背景图片
- 22. CSS背景图片错误?
- 23. CSS透明背景图片
- 24. CSS背景图片叠加
- 25. 整页CSS背景图片
- 26. 随机CSS背景图片
- 27. CSS背景图片太大
- 28. CSS,背景颜色/图片
- 29. 居中CSS背景图片
- 30. CSS背景图片:页
我只能说这个操作在今天的很多浏览器上都会很慢。您的用户在打开您的网站时会感到沮丧。也许你可以用动画gif达到你想要的效果。这可能会让你更快。 – ypnos 2010-06-16 16:45:07