CSS flex-flow 属性
CSS flex-flow 属性是 flex-direction 和 flex-wrap 的简写。
实例
使弹性项目以反方向显示,并在需要时换行:
<!DOCTYPE html><html><head><style>#main {width: 200px;height: 200px;border: 1px solid #c3c3c3;display: flex;flex-flow: row-reverse wrap;}#main div {width: 50px;height: 50px;}</style></head><body><h1>flex-flow 属性</h1><div id="main"><div style="background-color:coral;">A</div><div style="background-color:lightblue;">B</div><div style="background-color:khaki;">C</div><div style="background-color:pink;">D</div><div style="background-color:lightgrey;">E</div><div style="background-color:lightgreen;">F</div></div><p><b>注释:</b>Internet Explorer 10 以及更早的版本不支持 flex-flow 属性。</p></body></html>
定义和用法
flex-flow 属性是以下属性的简写属性:
- flex-direction
- flex-wrap
注释:如果元素不是弹性项目,则 flex 属性无效。
| 默认值: | row nowrap |
|---|---|
| 继承: | 否 |
| 动画制作: | 不支持。请参阅:动画相关属性。 |
| 版本: | CSS3 |
| JavaScript 语法: | object.style.flexFlow="column nowrap" |
浏览器支持
表格中的数字注明了完全支持该属性的首个浏览器版本。跟随 -webkit-、-ms- 或 -moz- 的数字规定使用前缀的首个版本。
| 属性 | |||||
|---|---|---|---|---|---|
| flex-flow | 29.021.0 -webkit- | 11.0 | 28.018.0 -moz- | 9.06.1 -webkit- | 17.0 |
CSS 语法
flex-flow: flex-direction flex-wrap|initial|inherit;
属性值
| 值 | 描述 |
|---|---|
| flex-direction | 可能的值:
默认值为 "row"。 规定弹性项目的方向。 |
| flex-wrap | 可能的值:
默认值为 "nowrap"。 规定弹性项目是否应换行。 |
| initial | 将此属性设置为其默认值。参阅 initial。 |
| inherit | 从其父元素继承此属性。参阅 inherit。 |
相关页面
CSS3 教程: CSS3 弹性框
CSS 参考手册:flex-basis 属性
CSS 参考手册:flex-direction 属性
CSS 参考手册:flex-grow 属性
CSS 参考手册:flex-shrink 属性
CSS 参考手册:flex-wrap 属性