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
Daniel Barone
1,630 PointsMy nav bar keeps shifting out of its bootstrap "div container" when I set it to a fixed position at the top of the page.
Here is a picture of the navigation bar properly in its div container before I fix it to the top of the page: http://i.imgur.com/9fxd3SL.jpg
Here is a picture of it after i run the code to fix it at the top of the page: http://i.imgur.com/9CNN5YZ.png
As you can see, it has broken out of the div.container. Does anyone know why this might be happening? Thanks!
1 Answer
Tyler Haas
20,623 Pointsper mdn:
Fixed positioning
Fixed positioning is similar to absolute positioning, with the exception that the element's containing block is the viewport. This is often used to create a floating element that stays in the same position even after scrolling the page.
basically fixed positioning will break the element out of its normal flow and make its new containing block the viewport. I don't know how to fix it without seeing your code. If you can post it here I can try to help you troubleshoot the problem.
Daniel Barone
1,630 PointsDaniel Barone
1,630 Pointsignore the addition and removal of the "container" classes under the if else statements. I only put that as a temporary fix to the navigation bar moving out of place
Daniel Barone
1,630 PointsDaniel Barone
1,630 Pointsi figured out the problem, thanks