Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Tyler Halstead7,987 Points
Why do you have to target individual classes when using the display property, but not the align-items property?
It seems like in order to display main-header and main-nav as flex, they both have to be directly targeted in CSS, yet if you wanted to center align the list in main-nav, you can just target .main-header and use align-items. Are the 2 properties treated differently in some way?
I think your talking about the relation between parent (container) and children (items) in flexbox.
Flexbox uses the relationship between the two to create the layout. As above you mentioned adding display flex to the container will define the element as a flexbox container. Adding align items center is now talking about all direct children to that container.
so if main-header is defined as a flex container and the direct children is the main-nav then using the
align-items property will target all direct children on the main-header.