1
這是fiddle!
圖像應該向上移動,直到底邊到達div的底部,然後向下移動,直到頂邊到達父div的頂邊,以顯示它。
這必須使用不同大小的圖像。jQuery動畫:在較小高度的div上移動圖像,使用overflow:隱藏
HTML:
<div class="container">
<img class="image" src="http://www.hotel-aramis.com/slider/home/notre-dame-de-paris.jpg />
</div>
CSS:
.container {
position:relative;
width:1100px;
height:480px;
overflow:hidden;
background-color:#000;
}
.image {
position:absolute;
max-width:100%;
min-width:100%;
}
的jQuery:
$(document).ready(function() {
move();
});
function move() {
$(".image").animate({
bottom: "-=50%"
}, 10000, 'linear', function() {
$(".image").animate({
bottom: "+=50%"
}, 10000, 'linear', move);
});
}
那麼有什麼不工作!我的意思是你面臨什麼問題? –
問題是我希望它只顯示圖像,從上到下。正如你可以在小提琴中看到的,父div的背景正在顯示。 – alex