2014-10-17 33 views
2

我需要在从服务器加载图像之前设置微调器。如何在图像加载表单服务器时设置小型微调图像。我如何设置预加载图像上的图像loding从服务器

喜欢这里是HTML

<img src="/imge/abc1.jpg" /> 
</br> 
<p>This tesst text</p> 
<img src="/imge/anyname.jpg" /> 
</br> 
<p>This tesst text</p> 
<img src="/imge/any.jpg" /> 
</br> 
<p>This tesst text</p> 
<img src="/imge/allname.jpg" /> 
</br> 
<p>This tesst text</p> 

像Facebook这样的节目微调图像加载 之前,所以我只需要更换<img>到这里的图像加载。 所以在此我怎么可以设置小微调用户可以实现图像加载这里

回答

1

如果你想要做CSS只需在代码上写上<head>标签

<style type="text/css"> 
img { 
    min-width:50px; /* if load.gif have 50px width */ 
    min-height:50px; /* if load.gif have 50px height */ 
    background: url('load.gif') no-repeat; 
} 
</style> 
0

这可能做的伎俩

只需添加背景图片img标签。所以CSS会

img{ 
     background:url(your laoding image) 
} 

编辑:或者你可以添加使用JavaScript 要遵循的步骤
1.第一负载你默认的图像(您加载图片)
2.装入原始图像,但一定要设置它的DIS图像播放属性设置为无
3.再经过一段时间改变显示属性以阻止(并确保删除您的默认图片)

0

使用FontAwsone微调:http://fontawesome.io/icon/spinner/

使用发旋类得到任何图标旋转。与fa-spinner,fa-refresh和fa-cog一起工作良好。

<i id="spin" class="fa fa-spinner fa-spin"></i> 

然后使用beforeSend:的setTimeout在AJAX来显示所述装载旋转器的图像出现之前, 例如:

setTimeout(function(){ 
      $('#spin').show(); //spin is the id of the spinner in <i> tag 
      },2000); // 2000ms: spinner appear for 2 seconds before the image appear 

然后使用更迭:显示图片