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 trialCharlie Person
8,692 PointsIf the main nav has the class of grid-8 which has a width of 66%, shouldn't it take up 66% of the viewport?
(Not really understanding how these percents are working)
Marcus Parsons
15,719 PointsI can't upvote Matthew's comment, but if I could, I would. Width is relative to the containing element unless a different positioning scheme is used.
Ehsan Raza
263 PointsBut it did take 66% of the width. you can check it if you put make a border around it and you will see it did take 66% of the view port width.
Marcus Parsons
15,719 PointsThe only reason it looks like it takes up 66% of the viewport width is because the "grid-container" class doesn't have a specific width which means that the "grid-container" will stretch the width of the page, which will, in turn, allow each grid placed within the container to have its width applied to the viewport. If you give the "grid-container" class a specified width, that 66% will still apply but you will visibly see that it is not 66% of the viewport; it is 66% of its parent element, the element with class "grid-container".
Ehsan Raza
263 PointsYes i meant 66% of the parent container which is "grid-container". But i thought Charlie Person meant why the main-nav not appearing as as 66% wide. So my answer to him was it was the main-nav that streaches not the main-nav list items.
Antonio Jaramillo
15,604 PointsOne way to understand what's going on is to change the li items to display: block. You will see that they do indeed take up 66% of .grid-container. Because they are set to inline-block, however, they only take up as much space as is necessary to contain their text; for example, the first child only takes up enough space to contain "Link 1" and whatever additional padding we set. That being said, .main-nav takes up the entire 66% of grid-container that we expect it to. We just don't see that because .main-nav has no background color.
Matthew Greenberg
8,173 PointsMatthew Greenberg
8,173 PointsNo, Its only going to take 66% of its parent's width.