tags:

views:

535

answers:

1

Hi,

I'm working on a pure css menu that consists of four levels

Level 1 and 2 are a dropline menu in style Levels 3+ are dropdown menus

When you hover over a level 1 menu item, the level 2 menu displays directly below menu item you are currently hovering over. However if there are lots of menu items on level 2 then the level 2 menu goes off the screen and you see a horizontal scroll bar.

What I want to happen is that if the menu is going to go off the screen I want it to get pushed to the left. For example, if the menu was 300px long, but there was only 250px between the level 1 menu item and the edge of the page, then the level 2 menu should not be placed directly under the level 1 parent, instead it should be 50px to the left.

I use a nested unordered list for the menu.

A: 

For that sort of logic I think you'll need a JavaScript-based solution.

Richard Ev
thanks for your comment - im going down the javascript route at the moment.I've got it working in Firefox, I have a method that calculates the available pixels on the page, and calculates the size of the span elements within 2nd level <ul>I'm currently hitting problems with IE6 - if i set the style of the unordered list using parent.getElementsByTagName('ul')[0].style.width = submenuWidth + "px";Then when I stop hovering over the menu - the border around the second level menus <li>'s and an image within the <li> remain (although the span containing the menu text disappears)
Simon