我在網站標題中有圖片作爲背景。現在,當頁面加載時,我想從左向右緩慢移動(大約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. CSS移動背景圖像
- 3. jQuery的CSS動畫,背景圖片
- 4. 製作CSS背景圖片滾動
- 5. 背景圖片在移動設備上
- 6. 在循環中移動背景圖片
- 7. 移動背景圖片放大
- 8. 背景中的可移動大圖片
- 9. CSS背景圖片疊加
- 10. 隨機CSS背景圖片
- 11. CSS - 背景圖片拉伸
- 12. 變暗CSS背景圖片?
- 13. css兩個背景圖片
- 14. CSS透明背景圖片
- 15. CSS - 旋轉背景圖片
- 16. html/css無背景圖片
- 17. CSS背景圖片 - >使用圖片
- 18. CSS:背景圖片/顏色和容器不舒展上移動對移動
- 19. CSS/JS幻燈片的背景圖片
- 20. 15拼圖背景圖片JavaScript/CSS
- 21. jQuery:動畫背景圖片
- 22. 動畫背景圖片
- 23. 滾動背景圖片
- 24. 移動視圖的背景
- 25. 移動固定圖像背景css,圖像滾動
- 26. 背景圖片
- 27. 背景圖片
- 28. css背景圖像被切入移動風景模式
- 29. CSS背景圖片加載行爲
- 30. PyQt WebKit CSS背景圖片不顯示
我只能說這個操作在今天的很多瀏覽器上都會很慢。您的用戶在打開您的網站時會感到沮喪。也許你可以用動畫gif達到你想要的效果。這可能會讓你更快。 – ypnos 2010-06-16 16:45:07