Center-aligned menu with JS

Tagged with Prototype Javascript

Language: JavaScript

This is the code used on SnippetStash to center the top menu horizontally.

View as text

Event.observe(window, "load", function(){
    var top_nav_lis = $$("#navbar ul li");
    top_nav_lis.each(function(li){ = (100/top_nav_lis.length + '%'); = "center";


Original snippet written by Brian Hogan
Last updated at 08:43 AM on Jun 06, 2009 by Brian Hogan

SnippetStash costs money to host and develop. The service is free for everyone to use
but if you found it useful please consider making a small donation.