在flexbox布局中,auto margins之所以有这么强大的功能,是因为它能够将剩余空间(free space)全部 “吃掉” 。没有了剩余空间,justify-content与align-self属性也无从下手,自然变得无效了。
来看几个例子吧~
Example 1: 实现flex元素的响应式水平垂直居中
.container { height: 300px; background-color: lavender; display: flex; flex-wrap: wrap; } .item { background-color: cornflowerblue; width: 100px; height: 50px; margin: auto; text-align: center; line-height: 50px; }
Item 1
查看更多关于用automargins来布局flexbox吧!以及学术一点儿的对比研究:automargins与a的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did111933