[英]column aligment for flex element with max-height
here is flex element with flex: column wrap;
这是带有
flex: column wrap;
flex 元素flex: column wrap;
and max-height: 150px;
和
max-height: 150px;
. . My problem is that
justify-content
not working.我的问题是
justify-content
不起作用。 But working with height: 150px
.但是使用
height: 150px
。 For container with max-width: 100%;
对于
max-width: 100%;
容器max-width: 100%;
& flex-direction: row;
&
flex-direction: row;
aligment works properly对齐工作正常
.container { max-height: 150px; display: flex; flex-flow: column wrap; justify-content: center; } .item { width: 25%; height: 50px; border: 1px solid #000; box-sizing: border-box; }
<div class="container"> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> </div>
Not sure if it's a bug or an intended result but you can fix it if you consider an extra wrapper where you apply the max-height
property:不确定这是错误还是预期结果,但如果您考虑使用额外的包装器来应用
max-height
属性,则可以修复它:
.container { display: flex; flex-flow: column wrap; justify-content: center; width:100%; } .item { width: 25%; height: 50px; border: 1px solid #000; box-sizing: border-box; } .extra { max-height: 150px; display:flex; }
<div class="extra"> <div class="container"> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> </div> </div>
Worth to note that if you consider height
instead of max-height
it works fine:值得注意的是,如果您考虑
height
而不是max-height
它工作正常:
.container { display: flex; flex-flow: column wrap; justify-content: center; height: 150px; } .item { width: 25%; height: 50px; border: 1px solid #000; box-sizing: border-box; }
<div class="container"> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.