[英]CSS flex-basis not working when flex-direction is 'column'
[英]Flex-basis is not acting as width when set within display: flex set to flex-direction: row
嗨,大家好,這里有更多詳細信息,包括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;
}
我試圖讓聖杯布局Flexbox的,我面臨着一個奇怪的行為flex-basis
被設置為主要標簽中display: flex
與方向row
。所以項目都排隊作為行。
當試圖設置flex-basis
而不是作用時或width
實際上只是作為height
而奇怪,考慮到flex-basis
拉伸取決於主標簽內的方向和主軸設置為row
的方向display: flex
默認為display: flex
。
是因為<body>
標簽設置為flex-direction:column
正在影響<main>
標簽項,因此在將主標簽項設置為flex-basis: 200px
實際上是作為列中的單個項響應,就像另一個標簽內的項目(導航,旁邊,文章)由於在主要內部的彎曲行方向下而在側面伸展。 認為這將是原因。
然而,經過一些研究后,我在csstricks上讀到設置為display: flex
項目不會受到其他父項的影響。 因此,當孩子的個別物品成為父母時,他們在方向方面不再受前一父母的影響。 只是一個猜測,但會喜歡一些幫助。 我想通過將body標記設置為row來解決這個問題並且它運行良好,因為它們有不同的解決方法,但在這種特定情況下看起來很奇怪。
有什么理由為什么這樣?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.