Bar*_*aro 36 html css css3 flexbox
我的问题是我希望flexbox具有可变范围宽度,并且一切正常,但不是最后一行.我希望所有孩子都有相同的维度,即使行没有孩子(最后一行).
#products-list {
position:relative;
display: flex;
flex-flow: row wrap;
width:100%;
}
#products-list .product {
min-width:150px;
max-width:250px;
margin:10px 10px 20px 10px;
flex:1;
}
Run Code Online (Sandbox Code Playgroud)
我的flex div可以缩小到150px并且长到250px,但所有都必须具有相同的大小(显然我想要一个CSS解决方案,JS我知道的方式).
Mic*_*l_B 46
不幸的是,在当前的flexbox迭代(Level 1)中,没有干净的方法来解决最后一行对齐问题.这是一个常见问题.
有一个flex属性是有用的:
last-row
last-column
only-child-in-a-row
alone-in-a-column
这个问题似乎是Flexbox Level 2的高优先级:
尽管在flexbox中很难实现这种行为,但在CSS网格布局中它简单易行:
如果Grid不是一个选项,这里是一个包含各种flexbox hacks的类似问题的列表:
作为一种快速而肮脏的解决方案,可以使用:
.my-flex-child:last-child/*.product:last-child*/ {
flex-grow: 100;/*Or any number big enough*/
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14228 次 |
最近记录: |