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.
精彩评论