2011-11-06 18 views
2

我知道,我瘋了,考慮到我實際上只是在學習HTML。但我試圖爲我的兄弟設計一個網站,他真的想要這個。請對你的回答非常有針對性。我正在使用這個JQuery來淡入淡出圖片,所以也許我可以使用類似的東西來做到這一點?順便說一句,我希望圖像滑動到它的位置,而不是隻是在閃光燈中移動。如何讓圖像在HTML中移動位置?

謝謝!

+0

我甚至不知道JQuery的,但我敢肯定你是問什麼是內置的,你有沒有考慮過一眼。在文檔中?或者也許拍攝你的兄弟鏈接到文檔? – ObscureRobot

+1

通讀[jQuery api](http://api.jquery.com/),特別是['animate'](http://api.jquery.com/animate) – zzzzBov

+0

在這裏提出了一個類似的問題:http: //stackoverflow.com/questions/938655/jquery-moving-from-postion-x-to-position-y-slowly-animation – JohnZaj

回答

2

JQuery .animate()是一種可行的方法。設在

這裏 文檔和例子是quick demo

<!DOCTYPE html> 
<html> 
<head> 
    <style> 
div { 
    position:absolute; 
    background-color:#abc; 
    left:50px; 
    width:90px; 
    height:90px; 
    margin:5px; 
} 
</style> 
    <script src="http://code.jquery.com/jquery-latest.js"></script> 
</head> 
<body> 
    <button id="left">&laquo;</button> <button id="right">&raquo;</button> 
<div class="block"></div> 

<script> 
$("#right").click(function(){ 
    $(".block").animate({"left": "+=50px"}, "slow"); 
}); 

$("#left").click(function(){ 
    $(".block").animate({"left": "-=50px"}, "slow"); 
}); 

</script> 

</body> 
</html> 
+2

非常感謝你! – Matt