开发者

Best way to preload images when unhover state is text?

I am aware that using CSS sprites is the way to go when you use images for both states, but what about when you have text as the unhovered state & an image on hover?

There a few ways I can think of, but wondering which method is the best in peoples opinions?

I can think of doing it via JavaScript or loading it via a h开发者_JAVA百科idden CSS element.


Are you using CSS Sprites for other relevant images on your website?

If not, then you should do it.

Have your "other relevant images" and "menu images" in the same sprite image.

Even if it's just for one other image, it will mean your :hover menu images are automatically preloaded.


You can use the same sprite, just set the sprite to a transparent section, or background-position out of the button, and when in hover, set it to the right place and text-indent the text, if the button image has the text on it.

Most browsers won't preload hidden images.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜