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

Arturo Espinoza
Arturo Espinoza
9,181 Points

Navbar Help

I create a dropdown menu and I like it, but everything it dropdown it moves around other objects like the title and stuff. How can I set it so the dropdown fall over the rest of the object in its way and not move them around.

http://jsfiddle.net/m9vcr4d7/2/

3 Answers

Andrew Shook
Andrew Shook
31,709 Points

Try this:

ul li {
float: right;
width: 100px;
text-align: center;
line-height: 5px;
position: relative;
}
ul li ul {
display: none;
position: absolute;
max-width: 100%;
top: 100%;
left: 0;
}

can't promise it will fix all of your problems but its a start.

Arturo Espinoza
Arturo Espinoza
9,181 Points

Definitely a start. It did fix one issue so thank you. I added a new link so people can see the second issue: http://jsfiddle.net/m9vcr4d7/4/ It still overlaps other list items <li>

Andrew Shook
Andrew Shook
31,709 Points

When does it overlap other list items?

Arturo Espinoza
Arturo Espinoza
9,181 Points

when the page changes size.

Arturo Espinoza
Arturo Espinoza
9,181 Points

So I know where the issue is I just cant fix it. If you change window size to 540px or less, it should display a vertical menu. It does that but if you select the ROOMS tab for example it will appear off and you cannot select any options from the dropdown menu.

This is what Im going for: http://codecanyon.net/item/modern-vertical-menu/2168420?ref=weblees&ref=weblees&clickthrough_id=271049763&redirect_back=true

Updated CSS code

nav:after {
  content: "";
  display: table;
  clear: both;
}
ul{  /* displays*/
  padding: 0;
  list-style: none;
  text-align: right; 
  max-width: 100%; 
  background: #000;

}

ul li{  /* location of the nav bar*/
  float: right;
  width: 100px;
  text-align: center;
  line-height: 5px;
  position: relative;
}

ul li a{ /* look of nav bar*/
  display: block;
  padding: 12px 7px 12px 7px;
  color: #fff;
  background: #000;
  text-decoration: none;
  font-family:Palatino Linotype Bold;
  font-size: 12pt;
}

ul li a:hover{
  color: #D3741C; /* displays color when mouse hovers*/
}

ul li ul{ /* displays dropdown menu*/
  display: none;
  position: absolute;
  max-width: 100%;
  top: 100%;
  left: 0;
}

ul li:hover ul{
  display: block; /* display the dropdown */
}

ul li:hover ul a{
  background: #ccc; /* display the dropdown color*/
}

.active {
  color: #D3741C; /* displays color on selected tab*/
}

/********************************
Tablets
*********************************/

@media screen and (max-width:540px) {
   .panov, #pano {
       display: none;}
  nav {
      display: inline;}
nav:after, ul li, ul li a, ul li a:hover, .active, ul li:hover ul, ul li:hover ul a{
     display: block;
     font-size: 100%;
     margin: 0;
     padding: 8px;
     text-align: center;
     list-style-type: none;
     font-weight: bold;
     width: 100%;
     text-decoration: none;}
ul li:hover ul, ul li:hover ul a{
    margin: 5px;
    padding: 8px;
}
 ul li ul, {
       display: none;}
}