加载图像时在图像内显示加载指示器

发布于 2024-11-25 09:06:52 字数 695 浏览 3 评论 0原文

我非常喜欢这里呈现的效果:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

檐上三寸雪 2024-12-02 09:06:52

如果您使用的背景图像被缓存,您可以这样做,

img {
  display: block;
  background-image: url(...);
  background-position: center center;
}

它应该出现在图像之前。 (注意透明图像,因为它们后面有背景。)

You could do

img {
  display: block;
  background-image: url(...);
  background-position: center center;
}

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.)

倥絔 2024-12-02 09:06:52

在大多数情况下,爱丽儿的方式会有帮助。然而,在网站的第一次加载时,您将无法看到加载图像,因为某些浏览器在开始加载图像(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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文