Rollover CSS Image Menu

Visited 12306 times | Submited on 2007-05-15 08:54:32

There are now loads of places on the Internet where one can access free CSS menu's. But of the many that are available very few suceed in replicating the prehistoric roll-over image menu using javascript image replacement techniques, with only lovely CSS. I have managed to create one that works in both decent web browsers and crap ones (Internet Explorer), view the finished CSS menu.

First I needed to remove all padding and margins from the page:

* { padding: 0em; margin: 0em; } 

Then the CSS for the #nav container div:

#nav img { border: none; }
#nav li { display: inline; list-style:none; }
#nav li a { float: left; display:block; width: 37px; height: 50px; margin: 5%; }
#nav li a img { border:none; vertical-align:bottom; /* for IE6 */}
#nav li a:hover { visibility:visible; /* for IE6 */ }
#nav li a:hover img { visibility:visible; /* for IE6 */ }
#nav li a:hover img/**/ { visibility:hidden; /* hide from IE5.0/win */}

Internet Explorer requires something to happen on a:hover as well as a:hover img.

The menu list items all use different images on rollover so I defined each with a different ID on the anchor element:

#one { background:url(1over.png) no-repeat left bottom; }
#two { background:url(2over.png) no-repeat left bottom; }
#three { background:url(3over.png) no-repeat left bottom; }
#four { background:url(4over.png) no-repeat left bottom; }

Lastly I created a div with an id of nav and applied the CSS into the final XHTML:

The Final Rollover CSS Image Menu XHTML.

By Alan Who



Comments (2)

  • On June 01, 2007 06:52 Apostrophe Man said:

    "free CSS menu's" should read "free CSS menus"

  • On September 10, 2007 13:51 Alan Who? said:

    HIi,

    I am AlanWho? from http://alanwho.com - the original author of this article. I just wanted to thanke you for publishing this menu and I hope people continue to find it useful.

    Thanks

    Alan
    http://alanwho.com - Helping You Win Online!

Add your comment

Name:(required)
E-mail address:(optional)
Comment:(required)
Repeat the number for validation: (required)

Browse by Tags:


Related Articles:

Text Link Ads

Statistics

Total 296 articles submitted
Latest submission at January 28, 2008 15:13

Feedback

Use this email below to send us your suggestions and feedback. We value your opinion.
info (at) theitarticles.com