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

mrx3
mrx3
8,742 Points

I have a question about why my text is not centered in my drop down mobile nav. (codepen included)

In the codepen link below, if you resize the image to show the drop down nav and click the "button", the drop down list is not centered. codepen link: http://codepen.io/mike316/full/qdYmom/ and if you resize the window as a far as possible, the words for the links get cut off.

But in this example, in line 174 of my code I have to add

nav ul {
  margin: 0;
  padding: 0;
}

This seems to center the text in the drop down menu. But I think I may be repeating code for example, in line 136 I have nav#nav-mobile ul. Should I add the margin: 0 and padding 0 to that part of the css instead. I'm really lost on what to do with this, and any help would be appreciated. Thank in advance. Codepen for the centered dropdown list: http://codepen.io/mike316/full/MwGmQW/

1 Answer

Sam Cooper
Sam Cooper
502 Points

Looking at your second pen, if you scrap the extra css on line 174 eg

nav ul {
    margin: 0;
    padding: 0;
}

And simply remove the padding being added to the ul by the user agent stylesheet (Chrome/ firefox or whatever) on line 136 eg:

nav#nav-mobile ul {
padding: 0;
}

Check out pen here: http://codepen.io/hogshouse/pen/MwGmLa

mrx3
mrx3
8,742 Points

Sweet!!!!! Thank you so much for the help Sam. I figured it had to be something with the mobile ul css selector. THANKS AGAIN!!!!!!!!!

mrx3
mrx3
8,742 Points

Hi Sam. Thanks again for your help. You fixed my navigation, and I'm giving you the best answer. I usually wait a day or two, so I can see if anyone else will reply with another answer. Thank you again Sam for your help.