[英]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.