简体   繁体   English

Gif图片有时没有显示,但显示了替代文本?

[英]Gif image is not displaying sometimes but alt text is displaying?

during page transition am using gif image to represent as 'loader' .But first 2 or 3 navigation i can see the image and rest of the transition instead of image am only able to see the "alt" text i have give with blank imagebox. 在页面过渡期间,我使用gif图像表示为“加载程序”。但是在前2或3个导航中,我可以看到图像,其余的过渡(而不是图像)只能看到我用空白imagebox给出的“ alt”文本。

I think the image is not loading,please check my code 我认为图片未加载,请检查我的代码

<div id="loadinggif" class="overlay"  align="center" style="display:none;">
<img src="img/gif.gif" alt="loader" height="50" width="50">
</div>

and when i click one page navigation am using following code 当我单击一页导航时,正在使用以下代码

$('#loadinggif').css('display','block');

Please check my screen shots first one is working perfectly ,second screnshots showing the exact problem am facing now. 请检查我的屏幕截图,第一个截图是否工作正常,第二个截图显示当前正面临的确切问题。 在此处输入图片说明

在此处输入图片说明

Are your 'pages' in the same file/location? 您的“页面”是否位于相同的文件/位置? Make sure the relative path to your image is correct everywhere you use it. 确保图像的相对路径在所有使用位置均正确。

Another thing would be to clear your browser cache. 另一件事是清除浏览器缓存。

If you still cannot get it to work, I would suggest inspecting it when it doesn't load, and looking at the browser's console. 如果仍然无法正常工作,建议您在未加载时进行检查,并查看浏览器的控制台。 Depends on the browser, but most you can right click the image then 'inspect element', or something very similar. 取决于浏览器,但是大多数您可以右键单击图像,然后单击“检查元素”,或者非常相似的东西。

Try to fully qualify the image. 尝试完全限定图像。 Such as https://mywebsite.com/img/spinner.gif . https://mywebsite.com/img/spinner.gif Now, if that fails, do not give up on life, there is still hope! 现在,如果那失败了,不要放弃生命,仍然有希望! What I normally do, is have a div with a css/Less class that has the image in it. 我通常要做的是在具有div的css / Less类中添加图像。 That way, the image is loading through the dom, and to hide n show, simply hide n show the dom element with that specific class. 这样,图像通过dom加载,并且要隐藏n show,只需隐藏具有特定类的dom元素。

Let me know if that works. 让我知道是否可行。

Cheers M8. 干杯M8。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM