jquery - 图像列表的多个加载微调器

标签 jquery html image css animated-gif

尝试在单个图像完成加载但遇到问题时删除加载动画。加载第一个图像后移除加载动画,而不是在加载特定图像时单独移除。

我想要一排图像,每个图像都有自己的加载 giff,有什么想法吗?

这是我到目前为止想出的......

.img-container{
float:left;
width:500px;
height:500px;}
.img-loading{
position:absolute;
background:url('loading.gif') center center no-repeat;
width:500px;
height:500px;}

<div class="img-container"><div class="img-loading"></div><img src="example.jpg"    height="500" width="500" border="0"/></div>
<div class="img-container"><div class="img-loading"></div><img src="example2.jpg" height="500" width="500" border="0"/></div>
<div class="img-container"><div class="img-loading"></div><img src="example.jpg3" height="500" width="500" border="0"/></div>

$(document).ready(function(){
$('img').css({'display':'none'});
$('img').bind('load', function () { $(this).fadeIn(1500);$('.img-loading').fadeOut(2000);});                
});

最佳答案

你只需要稍微改变一下淡出:

$('img').bind('load', function () { $(this).fadeIn(1500).prev().fadeOut(2000);});

这会淡入图像并获取它之前的元素并将其淡出。

关于jquery - 图像列表的多个加载微调器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12428051/

相关文章:

javascript - 使用 Javascript 在 MouseOver 上的其他元素之上显示 Html 元素

javascript - 使用 x 和 y 位置设置文本区域的插入符号位置

swift 3 : image does not fit to circle border

php - 通过 PHP 将多个图像和数据上传到 MySQL 数据库的表单

javascript - 地理定位API : how to know if the user clicked on close or block button

jquery - 删除组内元素的类以进行同位素过滤

javascript - 我的设备重叠,条件不工作

python - Pygame 中的透明图像

jquery - 您希望在不对表单当前标记进行任何更改的情况下添加哪个 jquery 表单验证插件?

html - 解码包含 HTML 的 json