2

I don't know how to formulate my question perfectly, so I made a (quick) example so will illustrate my problem exactly : http://jsfiddle.net/kn5GT/1/

If the last item is near the bottom and you hover it, the submenu will be displayed like the other, but this will extend the height of the page, thus showing the vertical scrollbar of the browser.

I'd like to avoid that by making all dropdown that would extend the height of the page by showing not from the up, but from the bottom (the bottom of the submenu would be near the end).

Is this possible only in CSS or do I have to put some js in it?

2
  • Gut feeling is that you're going to need JavaScript, but there might be CSS available I'm unaware of... so I am not going to "answer" Commented Jul 13, 2012 at 8:29
  • I'm in the same state of mind :) Pretty sure only JS can do it, but maybe I don't know about a magic css property :) Commented Jul 13, 2012 at 8:36

1 Answer 1

2

this might not be the best solution, but you could fix this with a little help of the css-pseudoclass nth-last-of-type().

I have modified your fiddle (the borders are just there for better visual distinction.)

I just added the following rule:

ul>li:nth-last-of-type(-n+2)>div {
    top:auto;
    bottom: 50px;
}

Don't get confused by the strange selector, essentially (-n+2) makes the last 2 Submenus pop up from the bottom instead from the top.

Sign up to request clarification or add additional context in comments.

1 Comment

@Cyril I added an additional rule for a nicer transition in the middle element, check out this fiddle (You have to adapt your arrows though)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.