Javascript free rollovers
I’ve talked about image rollovers on this site before, but I’ve never seen a technique I like half as much as Pixy’s Fast rollovers, no preload needed. Like all good techniques, it’s so simple I’m surprised no one has thought of it before. The trick is that a single image is loaded containing the different rollover states, then positioned as the background of a fixed pixel size link element in such a way that only one of the states is shown. The :hover style simply changes the offset of the background, revealing the secondary (or even tertiary) state.
Bob - 10th September 2003 18:10 - #
Eric - 10th September 2003 18:47 - #
Warren - 10th September 2003 19:01 - #
Warren, I didn't look at your CSS or source coding. I assume that for your technique to work, the container has to be fixed-width. Otherwise, it seems that you'd have the same problem as the text expanded horizontally.
Fixed width containers pose their own special challenges when coupled with resizable text.
Eric - 10th September 2003 19:39 - #
Warren - 10th September 2003 20:30 - #
I really like Pixy's trick, all smart CSS solutions for that matter.
There is a downside to this solution though. It (obviously) requires you to download all the images, or actually a 'larger, combined' image. When you have a lot of navigational links, all images would be loaded, instead of just the one requested. I know this might not be a big issue with people on DSL or cable... But it would increase the download-time for the complete page...
When I browse some website I often use only a few navigational links. Isn't this just 'moving the problem to another area'?
(It is ofcourse much better than Javascript rollovers!)
Dave - 10th September 2003 21:48 - #
Josh - 10th September 2003 21:50 - #
Josh - 10th September 2003 22:00 - #
Thomas Scholz - 11th September 2003 02:40 - #
Rob Ballou - 11th September 2003 04:10 - #
From My P.O.V This Is A Hack.
The CSS Spec Defines _Direct_ Method Of Contolling Hovering Over An Object - :Hover Selector. And It's The Browser's Task To Make A Decent Implementation Of 'Hovering' Metaphor. I Mean It's Not That Hard For A Browser To Automatically Preload Background-Image Specified In :Hover CSS Rules.
This Method Is A Workaround For The Weakness Of Contemporary Browsers' Implementation Of Hover. This Is The Same Old Way Of Writing For A Browser, Not For A Standard. That's Why I'm Not So Impressed With It. If Designers Again Invent Workarounds For Everything Then Why Browser Makers Should Bother Implementing It Better?
Maniac - 11th September 2003 08:50 - #
Josh, I agree with you on that. If you use just 2 images ('normal' and 'hover' state) and continue to use only 'instances' of those two...
Thomas, it would require more requests while the whole page is loading, I'm actually not sure if 1 combined image is smaller then 2 seperate ones, seperately they load faster and you would notice the effect sooner... So I guess it depends on how much different images you use, using a lot of different images actually could increase the overall loading time. Especially when most of those aren't used because they are not 'hovered'...
Maniac, how exactly would current browsers preload the hover-state-images (defined in a CSS sheet)??
Dave - 11th September 2003 09:40 - #
I was converting someone else's layout to use xhtml/css and as a handy excuse to try out this technique as well as the negative text-indent one which was mentioned on phark.net. All is well on Firebird, but IE6 seems to reload the whole image on :hover, creating a nasty flickering effect:
http://www.dti.barrysworld.net/web/cellison/insin - 11th September 2003 09:55 - #
I noticed the same flickering as Insin with IE6 :/ But If you access the page from your cache this works great ! :p
Here's a small demo (Icelandic) I made the other day using this method.
Andri Sigurðsson - 11th September 2003 13:36 - #
Thomas Scholz - 11th September 2003 16:32 - #
Those experiencing flicker in IE6 - try turning off IE's checking for a new file every time it's displayed.
Tools > Internet Options > General > Settings (under Temporary Files) > check 'Automatically'
Note that most of the populace browses with this already set properly, so it shouldn't hinder anyone from using this technique. Only developers need it turned on.
Dave S. - 11th September 2003 21:03 - #
francois - 12th September 2003 09:52 - #
Andri, you want to take a look at your version in IE5,5. I can see you've tried to implement an exclusion for IE5,5, but the height of each <li /> is too big here and looks rather messy (and I can see the text for each item, which makes the menu very untidy).
Very elegant solution, though, I like it!
Of course, I prefer no images for navigation at all, myself. But I'm just a geekboi with no sense of æsthetics… ;o)
Owen Blacker - 12th September 2003 09:55 - #
Andrew Downie - 12th September 2003 16:09 - #
Andri Sigurðsson - 12th September 2003 22:33 - #
grimby - 6th January 2004 11:33 - #
sandra - 14th December 2005 23:20 - #