加载图像时在图像内显示加载指示器
我非常喜欢这里呈现的效果:
http://rascals.eu/templates/ rt0802/portfolios/portfolio-2-columns/
然而问题是,如果你查看源代码,你会发现没有任何东西 - 这都是通过 jquery 完成的和像这样创建的链接:
<a href="xxx.jpg" rel="lightbox[portfolio]" style="width: 446px; height: 205px" class="autoload hover" data-image_url="yyy.jpg"></a>
可能在后台创建图像,然后在加载时插入到该位置。
然而,这是否可以以不同的方式、更符合标准的方式实现?如果是的话,任何人都可以指导我获取任何资源/教程吗?
谢谢。
编辑:按照符合标准,我的意思是:
img src 指向正确的位置,以便在禁用 js 时图像仍然显示。
I quite like the effect presented here:
http://rascals.eu/templates/rt0802/portfolios/portfolio-2-columns/
The problem however is that if you look at the source code you'll notice that there aren't any - it's all done via jquery and links created like this:
<a href="xxx.jpg" rel="lightbox[portfolio]" style="width: 446px; height: 205px" class="autoload hover" data-image_url="yyy.jpg"></a>
with an image probably created in the background and then inserted in that location at load.
However, is this possible in a different way, more standards compliant way? Can anyone guide me towards any resources/tutorials if so?
Thanks.
Edit: By standards compliant I mean:
With the img src pointing to the correct location so that images still display when js is disabled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用的背景图像被缓存,您可以这样做,
它应该出现在图像之前。 (注意透明图像,因为它们后面有背景。)
You could do
If the background image you use is cached it should appear before the images do. (Watch out for transparent images, since they will have the background behind them.)
在大多数情况下,爱丽儿的方式会有帮助。然而,在网站的第一次加载时,您将无法看到加载图像,因为某些浏览器在开始加载图像(img 标签)后加载背景。下次,图像将被缓存,页面看起来会很好。正如已经提到的,这种方式对于不透明的图像很有用。
我通常自己使用这种背景技术来加载图像:)
In most cases, the Ariel's way will help. However, the very first load of the website, you won't be able to see the loading image though as some browsers are loading backgrounds after starting loading the images (img tag). Next time, image will be cached and the page will look good. And as was already mentioned this way is good for images which are not transparent.
I usually use this background technique with loading image myself :)