CSS Flexbox Posted on 2015-08-27 | In Front-End | 有一个容器: 1234567<div class="container"> <item class="item"></item> <item class="item"></item> <item class="item"></item> <item class="item"></item> <item class="item"></item></div> 设置容器如下: 123456789101112131415.container { display: flex; /* 内部项目排列方向 */ flex-direction: row | row-reverse | column | column-reverse; /* 是否换行和换行后反过来 */ flex-wrap: nowrap | wrap | wrap-reverse; /* 速写法 */ flex-flow: <'flex-direction'> || <'flex-wrap'>; /* 整理版面 */ justify-content: flex-start | flex-end | center | space-between | space-around; /* 排列内部项目 */ align-items: flex-start | flex-end | center | stretch | baseline; /* 排列内容 */ align-content: flex-start | flex-end | center | stretch | space-between | space-around;} 设置内部项目如下: 1234567891011121314.item { /* 排列顺序 */ order: <integer>; /* 是否拉长 */ flex-grow: <number>; /* default 0 means no flex grow */ /* 是否收缩 */ flex-shrink: <number>; /* default 0 means no flex shrink*/ /* 项目长度 */ flex-basis: <length> | auto; /* default set to auto */ /* 速写法 */ flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]; /* 自排列 */ align-self: auto | flex-start | flex-end | center | baseline | stretch;}