Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

How do I position drop down menus under main menu

how to position drop down menus under main menu

http://jsfiddle.net/j4b9ntmk/

3 Answers

In your CSS, add position: relative; in your ul rule

ul {
  position: relative;
  list-style-type: none; 
  float: right;
  font-size: 13px;
  margin: 25px 115px 25px 0;
  padding: 0;
  text-align: center;
  text-transform: uppercase;
 } 

You have the sub-menu positioned absolute so you need to make it's parent element positioned relative so that it stays contained inside of it.

I tried that but still doesn't work.

This doesn't work for you? https://jsfiddle.net/406somug/1/

I get what you mean now. I'm sorry. Add the position relative to the li rule NOT the ul. Also, in your nested ul, change the left property from auto to 0

Like this: https://jsfiddle.net/j4b9ntmk/12/

Here is my updated link. The sub menu doesn't appear directly under the menu I hover over. For example if you hover over "Contact" the dropdown appears in the same location as "Menu" and "Menu2''

http://jsfiddle.net/j4b9ntmk/8/

PERFECT! It worked. A million thanks.