Programmers ask me all the time. Meouzer! How do I make a great professional Menu that I can be proud of? I say it's just just six lines of CSS that form the basis of every great looking Menu!
Meouzer
The Dell menu is possibly the most killer menu we've seen. So we duplicate it by using six magic lines of CSS. Everything else is just mere sizing and positioning that can be done with eye to CSS coordination.
It is to be emphasized that the menu can have mixed vertical columns and horizontal rows. For example you might have a menu that goes vertical-vertical-horizontal-vertical-horizontal. Its easy to accomplish just by setting or not setting the row attribute of an unordered list.
The Six Lines of CSS to Make Menus Rock | ||
---|---|---|
1 | ul.menu, ul.menu ul
{ padding:0; list-style:none; } |
|
2 |
ul.menu li { margin:0; position:relative; white-space:nowrap; padding:0.5em; text-align:left } |
|
3 | ul.menu li > ul
{ visibility:collapse; position:absolute; left:100%; top:0; } |
|
4 |
ul.menu li:hover > ul { visibility:visible } |
When hovering over an item, show its menu if any. |
5 |
ul.menu.row, ul.menu ul.row { display:flex; } |
Allow row/horizontal menus and submenus |
6 |
ul.menu.row > li > ul, ul.menu ul.row > li > ul { left:0;top:100%; } |
Best default positioning of submenu of row menu |
It doesn't matter how broad or deep the menu goes
The six lines of code you must know
So don't be a fuddy
And this article do study
So you'll have great menus to show
OK! We prettified the menu after the basic six lines, but it needs to be emphasized that the basics work out of the box to accomplish 95% of the work that needs to be done.
To prove this point, see Unadorned Menu, which uses only one extra CSS statement beyond the basics. Also the ordered list on which the menu is based is just an ordered list with absolutely no markup except to indicate which ordered lists should be row menus. That means the basic six lines of CSS are very powerful stuff!
Markups we did for the menu displayed on this web-page are minor.