for example if the .nav-flex is the parent why arent my flex stylings appearing for my child anchor elements. I have to DISPLAY: FLEX on the child anchor element to make it appear flex.
(parent )
.nav-flex {
display: flex;
flex-direction: row;
}
(child) /i have to insert display: flex down here for flex to work/
a {
list-style-type: none;
text-decoration: none;
flex-grow: 1;
justify-content: space-around;
}
The flex layout box model has two concepts:
Flex containers
Flex items
Therefore,
.nav-flex { display: flex }makes the.nav-flexa flex container and makes theainside flex items.Since
aare flex items,flex-grow: 1will make them grow to fill all the.nav-flex.However,
justify-contentonly applies to flex containers, so it won't work.Instead, I think you want one of these (they are equivalent):
Since the
aflex items establish a new block formatting context for its contents, you can center its inline-level content usingtext-align:Remove the
flex-grow: 1to prevent theafrom growing, and use thejustify-content: space-aroundon.nav-flexto align them properly:Make the
aflex items so that their text content will be wrapped in a flex item, and align it withjustify-content: