How to make the perfect horizontal menu
Here's a simple way to make a menu like this:
CSS code:
- #menu {
- overflow : hidden;
- width : 500px;
- }
- #menu > li {
- float : left;
- width : 100px !important;
- }
- #menu .ui-menu {
- width : 200px;
- }
JS code:
- var menu = "#menu";
- var position = {my: "left top", at: "left bottom"};
- $(menu).menu({
- position: position,
- blur: function() {
- $(this).menu("option", "position", position);
- },
- focus: function(e, ui) {
- if ($(menu).get(0) !== $(ui).get(0).item.parent().get(0)) {
- $(this).menu("option", "position", {my: "left top", at: "right top"});
- }
- }
- });
- $(menu + " > li > a > span").switchClass("ui-icon-carat-1-e", "ui-icon-carat-1-s");
Feel free to use this code in any way. However, please write a reply if you have some improvements.
cu
Mr.Yeah