我正在寻找如何获得以下效果:http ://www.weareempire.co.uk/work/rob-evans-photography/
因此,当我向下滚动时,图像将在特定高度淡入。
我的标记:
<ul class="grid_12" id="portfolio-entrybox">
<li><img src="../images/designstyle-2.jpg" alt=""></li>
<li><img src="../images/designstyle-3.jpg" alt=""></li>
<li><img src="../images/designstyle-4.jpg" alt=""></li>
<li><img src="../images/designstyle-5.jpg" alt=""></li>
<li><img src="../images/designstyle-6.jpg" alt=""></li>
</ul><!-- End ul.grid_8 #portfolio-entrybox -->
更新:我现在想出了这个。这是可行的,但我希望淡入淡出启动得更快。所以列表项淡入到我的页面上,应该在底部的位置开始更快一点。
Java脚本:
/* Every time the window is scrolled ... */
$(window).scroll( function(){
/* Check the location of each desired element */
$('#portfolio-entrybox li').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).animate({'opacity':'1'},500);
}
});
});