4 basic examples (updated on Apr 17th, 2008)
ADxMenu.js 4.20 (included in the .zip above)
Free to use, Public Domain now.
It works using only CSS in all modern browsers: Firefox, Opera (9+ recommended), Safari, Camino, OmniWeb, Konqueror, IE7. For IE6 I developed small Javascript that circumvents the lack of li:hover
support in it. Take a look at the examples to see it action. Instructions are also given, along with troubleshooting hints for possible problems.
There is not much I need to say here (or so I hope). The examples I made will be your starting point and for anyone reasonably skilled with CSS it should be enough. The files are heavily commented and should be an easy read.
Here, I will emphasize the steps that you need to do, so you can better look for particular code in the examples.
Please remember my original goal: this is intended for the people building modern sites based on CSS layouts. You need (at least) intermediate CSS skill level in order to develop attractive menu designs. If you have a good grasp of concepts and techniques like "box model", "sliding doors", floating and positioning etc. - I believe you will do just fine. If not, you should first learn those.
With that out of the way, here we go.
ul
that is to be made into menu, must have a class of adxm
id
or class
to identify the menu (main, top-level list) - then use that to build the styles. My examples use a class of menu
ul
lists. They are specifically used to achieve "the sticky" - submenus would not instantly dissappear if your mouse sidetracks a bit while moving through the menu. If your design can't be implemented without the help of the nested ul
s, then you need additional div
around it. This example demonstrates such variation.li
which is hovered has adxmhover
class. This allows you to simulate li:hover
selector.a
element inside hovered item (its first child) has adxmhoverA
class. This allows you to simply simulate li:hover>a
selectorul
element inside hovered item has adxmhoverUL
class. This allows you to simply simulate li:hover>ul
selectorol
) too - just change the styles accordingly + change the ADxMenu.js
.These are 4 most basic examples.
These are the only ones that will always be updated to the latest version.
These examples will usually stay as they were at the moment of creation. Look for the last updated date at the bottom.
With non-semantic div
around each submenu, for the cases when you must style UL's background. Use this only when menu design absolutely requires this.
window.onload
; read: before all images, videos, Flash and similar external objects have loaded you need to be very quick and try using the menu as soon as it appear on the page. Compare that with version that uses window.onload
for menu setup.Did you analyze the examples? I did my best to keep them simple and commentful so you build whatever you need. If not, please do so.
If yes, then read on - these are the most frequent issues.
This is not the problem with the menu or CSS, but with the Adobe Flash plugin. To resolve it, you need to set the embedded content to be transparent:
<object ...>
<param name="wmode" value="transparent" />
</object>
<embed ... wmode="transparent" ... />
Being a standards-oriented developer, you are not using embed
,right? :)
IE6 and IE7 have serious bugs related to CSS position
rule. I have written a tutorial on this issue – I strongly recommend you read it.
In essence, make sure that the highest positioned element in the structure that contains the menu has the highest z-index
value.
select
elements in IE6This is a problem with IE6, and you need to use my WCH script. Simply load it before the ADxMenu.js and you'll be just fine. Like this:
<!--[if lte IE 6]>
<script type="text/javascript" src="PATH_TO_WCH/WCH.js"></script>
<script type="text/javascript" src="PATH_TO_ADXMENU/ADxMenu.js"></script>
<![endif]-->
I made an example to demostrate how ADxMenu and WCH work together.
You need to apply a width
for the vertical menus:
.menu { width: 12em; }
Use the value that fits your layout, but use it.
Remember this image?
"Sticky" areas around the submenu
There is a 30px (per my examples) of transparent space around the submenus. Thus, if you have, for instance, horizontal menu aligned to right and the submenu for the most right item opens at less then 30px from the right edge, you will have the scrollbars showing up. Similar goes for left-hand menus flushed to left edge of the browsers.
In order to avoid this, add an id
to the offending menu and do this (for left-hand case):
#THATid { margin-left: 0; padding-left: 0; }
Add !important
if necessary.
Kill entire "DESIGN styles" parts, bring back the original "BASIC styles" (if you have changed them) and start from scratch. Really, that's the best option, which I sometimes use myself.
Public domain, use as you wish, where you wish to.