预加载图像 CSS

发布于 2024-08-18 04:51:41 字数 703 浏览 2 评论 0原文

我在 Firefox 上预加载图像时遇到问题。在 (webkit) Chrome/Safari 上看起来不错。

我们来看一下。

我有 :hover 加载图像 css 文件:

.zz{background:url(../img/guzik_01_ofirmie_PL_A.png) no-repeat; height: 1px; width: 1px; position:absolute; } 

li#ofirmie{background:url(../img/guzik_01_ofirmie_PL_B.png) no-repeat; height: 44px; width: 108px; position: absolute; z-index: 1000;}

ul.menu li#ofirmie:hover {background:url(../img/guzik_01_ofirmie_PL_A.png) no-repeat; height: 44px; width: 108px; position:absolute;}

和 HTML

<div class="zz"></div>

<li id="ofirmie" ></li>

为什么 Firefox 不从缓存加载图像,而不是从服务器加载图像?

我该如何修复它?

I have problem with a preloaded image on Firefox. On (webkit) Chrome/Safari it looks fine.

Let's take a look.

I have :hover load image
the css file:

.zz{background:url(../img/guzik_01_ofirmie_PL_A.png) no-repeat; height: 1px; width: 1px; position:absolute; } 

li#ofirmie{background:url(../img/guzik_01_ofirmie_PL_B.png) no-repeat; height: 44px; width: 108px; position: absolute; z-index: 1000;}

ul.menu li#ofirmie:hover {background:url(../img/guzik_01_ofirmie_PL_A.png) no-repeat; height: 44px; width: 108px; position:absolute;}

and HTML

<div class="zz"></div>

<li id="ofirmie" ></li>

Why doesn't Firefox load the image from the cache, rather than from server?

How can I fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

谜兔 2024-08-25 04:51:41

As long as it's possible don't use two images. Use CSS Sprites technique. Then you just operate on background-position property instead of different images.

谎言月老 2024-08-25 04:51:41

或者您可以尝试使用 jQuery preloadCssImages 函数,这将确保您的图像在显示之前加载到缓存中,从而使您的页面更加流畅;

http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/

Or you can try using the jQuery preloadCssImages function, this will make sure your images are loaded into the cache before displaying and thus making your page much smoother;

http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/

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