I love the jQuery UI stuff!
I like the navigation menu, but I can't seem to get it horizontal. I've got to be missing something that's a cinch.
Anyone know how to change the CSS? I tried this but it is for an older version and doesn't work, since there is no longer "clear" to keep them on top of each other.
Relevant CSS:
.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; }
.ui-menu .ui-menu { margin-top: -3px; position: absolute; }
.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; }
.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; }
.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
.ui-menu .ui-menu-item a.ui-state-focus,
.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }
.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; }
.ui-menu .ui-state-disabled a { cursor: default; }
Thanks for the help!
This post has inspired me to try the jQuery ui menu.
http://jsfiddle.net/7Bvap/
http://jsfiddle.net/vapD7/
To get a horizontal nav bar with vertical dropdowns, use a combination of a table and unordered lists.
The level 1 items are represented by table cells, subsequent levels are represented by unordered lists.
The positioning of the child menus was a problem. The default is to have them appear directly alongside, but when on a top level item, that was obscuring the subsequent items in the horizontal nav bar. Having them appear below was ok for a single dropdown menu, but if there was a second level beneath, then that 2nd level would obscure the rest of the first. The solution is to have the menu open below and somewhat to the right, see the "position" option in the menu invocation.
I admire all these efforts to convert a menu to a menubar because I detest trying to hack CSS. It just feels like I'm meddling with powers I can't possibly ever understand! I think it's much easier to add the menubar files available at the menubar branch of jquery ui.
I downloaded the full jquery ui css bundled file from the jquery ui download site
In the head of my document I put the jquery ui css file that contains everything (I'm on version 1.9.x at the moment) followed by the specific CSS file for the menubar widget downloaded from the menubar branch of jquery ui
Don't forget the images folder with all the little icons used by jQuery UI needs to be in the same folder as the jquery-ui.css file.
Then at the end the body I have:
That's a copy of an up-to-date version of jQuery, followed by a copy of the jQuery UI file, then the menubar module downloaded from the menubar branch of jquery ui
The menubar CSS file is refreshingly short:
but the menubar JavaScript file is 328 lines - too long to quote here. With it, you can simply call menubar() like this example:
As I said, I admire all the attempts to hack the menu object to turn it into a horizontal bar, but I found all of them lacked some standard feature of a horizontal menu bar. I'm not sure why this widget is not bundled with jQuery UI yet, but presumably there are still some bugs to iron out. For instance, I tried it in IE 7 Quirks Mode and the positioning was strange, but it looks great in Firefox, Safari and IE 8+.
You can do this:
and also set:
I know this is an old thread but I was digging into the jQuery UI source code and built upon Rowan's answer which was closer to what I had been looking for. Only I needed the carrots as I felt it was important to have a visual indicator of possible submenus. From looking at the source code (both .js and .css) I came up with this that allows the carrot be visiable without messing with design (height) and also alowing menu to appear vertical below the parent item.
In the jquery-ui.js do a search to find
$.widget( "ui.menu")
and change postition to:And in your css add:
End Result will be a jQuery UI Menu horizontal with sub menus being displayed veriticaly below the parent menu item.
The best option I found is a plugin called jMenu.
Main: http://www.myjqueryplugins.com/jquery-plugin/jmenu
Demo: http://demos.myjqueryplugins.com/jmenu/
GitHub: https://github.com/alpixel/jMenu
Screenshot: