0
第二張圖像如何淡入。我認爲它與z-index
和opacity
有關。 jQuery fadeIn不適用於Z-index
$(document).ready(function() {
$(window).scroll(function() {
$('.fade-in').each(function(i) {
var bottom_of_object = $(this).position().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* If the object is completely visible in the window, fade it it */
if (bottom_of_window > bottom_of_object-$(this).outerHeight()/2) {
$(this).animate({
'opacity' : '1'
}, 500);
}
});
});
});
.fade-in {
opacity:0 ;
}
.row {
position: relative;
width:100%;
height: 600px;
background: #000000;
}
.offset {
height:1000px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="offset">scroll down</div>
<div class="row">
<img src="http://assets3.parliament.uk/iv/main-large//ImageVault/Images/id_7382/scope_0/ImageVaultHandler.aspx.jpg" alt="test" class="fade-in"/>
</div>
<img src="http://assets3.parliament.uk/iv/main-large//ImageVault/Images/id_7382/scope_0/ImageVaultHandler.aspx.jpg" alt="test" class="fade-in"/>
你實際上是試圖重新創建**的圖像延遲加載** ...只是沒有延遲加載? – 2014-09-25 00:52:49