演示网站:http://83.249.244.210:8080/img/
尝试在Firefox中刷新网站几次。当图像淡入时,其中一些会闪烁一些。有人可以解释一下原因吗?
这是我加载图片的方式:
$(function(){
$.post('service.php?getPhotos', function(data){
var loadCount = 0;
$.each(data, function(){
$.post('service.php?getImage', { id: this.id }, function(data2){
loadCount++;
var $galleryItem = $('<div/>')
.hide()
.attr({ 'class': 'galleryItem' })
.html('<a href="'+ data2.photo.id +'"><img src="http://farm'+ data2.photo.farm +'.staticflickr.com/'+ data2.photo.server +'/'+ data2.photo.id +'_'+ data2.photo.secret + '_q.jpg"/></a><h3>'+ data2.photo.title._content +'</h3><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent euismod ultrices ante, ac laoreet nulla vestibulum adipiscing.</p>');
$('#container').append($galleryItem);
$galleryItem.find('img').load(function(){
$galleryItem.fadeIn(200);
});
});
});
});
});
答案 0 :(得分:1)
也许在jQuery淡入之前尝试用css隐藏图像?
#container > div {
display: none;
}