/    Sign up×
Community /Pin to ProfileBookmark

Issue with menu hover images delay

Hi

I have a simple CSS menu with two images, one image is the primary display image and the other is the image that is used to give a colour change on hover.

The problem is in a lot of browsers, (Firefox mostly and IE), the hover image delays loading and the image does not appear instantly, leaving the menu a blank white space for about half a second and looks very buggy.

How can I fix this without Javascript?

Can I pre-load the images with css or do I need Java-script and if I do can I just pre-load the images with JS, then leave the rest to css?

Dan

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@WestWebNov 21.2012 — It's fairly common to just combine the two images into one image, hide the active part with overflow: hidden; and defined dimensions: then on hover, move the image so the active part shows.

I can make an example if you want more clarification?
Copy linkTweet thisAlerts:
@drunken_devauthorNov 21.2012 — Thanks I know what you mean, it sounds like a good way to do it.

In the meantime (before I read your reply)I have used another method where you load them in a far corner as width 1px height 1px then hide them with css.

Not my preferred method, but seems to work for now.

Dan
Copy linkTweet thisAlerts:
@rtretheweyNov 21.2012 — The problem is, as you suspect, that the browser hasn't loaded the second image until the user actually hovers over the link. You could use CSS sprites, which is a very useful method of speeding up page loading and solves this problem. But until you learn a bit more, I'd suggest simply using JavaScript to preload the images you have. A Google search should show you plenty of examples.
×

Success!

Help @drunken_dev spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...