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 trialMustafa Khan
6,224 PointsFix my nav bar
I'm trying to make my nav bar at the top span the whole page. I want the darker shade to go from edge to edge, but the placing to remain the same. How do I do this? Here is a snapshot: https://w.trhou.se/fssriohmdw
1 Answer
Cody Selman
7,643 PointsHello Mustafa,
The left and right margin of 12em being attributed to the body is preventing the content of your page from taking up the full width of the screen. We'll need to remove that and have a left and right margin of 0 instead. Making this change alone will cause the background-color of the nav bar to stretch the full width of the window.
If you'd like for the content of the nav bar, .main-header, and <p> sections to maintain their padding or margin, we'll need to adjust that as the above change will also make their content expand to the full width of the window. Unfortunately, we won't simply be able to use the 12em left and right margin you were using for the body, as em is a relative unit and the padding/margin will be different if we use 12em for the nav-bar, .main-header, and <p> sections. I found that a left and right padding of 15% was about right.
Feel free to check out my snapshot of this solution.
Mustafa Khan
6,224 PointsMustafa Khan
6,224 PointsThanks, I really appreciate this! I'm a little rusty after a long break, and every bit of help counts!