Hi guys here is the codepen for more details including html: [https://codepen.io/Onsopen/pen/BmvNJe?editors=1100][1]
body {
display: flex;
margin: 0;
flex-direction: column; // so here i am using body tag as overall container
min-height: 100vh;
background: #2c3e50;
}
header {
display: flex;
justify-content: space-between;
}
main {
display: flex; // <-here the main html tag is being set as display flex and by default is row direction.
flex-basis: 200px; // <-THE PROBLEM is the 200px are set as height??
}
article {
flex-basis: 60%; // <- over here i am setting the tags within main tag individually
background: #ecf0f1;
}
nav {
flex-basis: 20%; <- over here i am setting the tags within main tag individually
background: #95a5a6;
order: -1;
}
aside {
flex-basis: 20%; <- over here i am setting the tags within main tag individually
background: #3498db;
}
header, footer {
background: #1abc9c;
flex-basis: 100px;
}
I am trying to make holy grail layout with flexbox and I am facing a strange behavior from flex-basis
within the main tag which is set as display: flex
with direction as row
.So the items all line up as a row.
When trying to set the flex-basis
instead of acting on or as the width
is actually just acting as height
which is strange considering that the flex-basis
stretch is dependent on the direction and main axis which within the main tag is set to row
with display: flex
as default.
Is it because the <body>
tag set to flex-direction:column
is influencing the <main>
tag item thus when setting the main tag item as flex-basis: 200px
is actually responding as an individual item within a column, like the other items within tag (nav, aside, article) stretch on the side because of being under flex row direction within main. Was thinking that would be the cause.
However after some research I read at csstricks that items set to display: flex
are not influenced by the other parent above them. So kind of when Individual items that are child become parent they are not anymore influenced by the previous parent in terms of direction. Just a guess but would love some help. I figure out to solve this with body tag set to row and it worked well as their are different ways to solve it but on this specific situation seems strange.
Any reason to why so?