Style flexFlow 属性
让灵活的项目以列的形式显示,且不拆列:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>蜜蜂教程(mifengjc.com)</title>
<style>
#main {
width: 200px;
height: 150px;
border: 1px solid #c3c3c3;
display: flex;
flex-flow: row wrap;
}
#main div {
width: 50px;
height: 50px;
}
</style>
</head>
<body>
<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>点击“尝试一下”按钮设置 flexFlow 属性的值为 "column nowrap"。</p>
<button onclick="myFunction()">尝试一下</button>
<script>
function myFunction() {
document.getElementById("main").style.flexFlow = "column nowrap";
}
</script>
<p><b>注意:</b>Internet Explorer 和 Safari 不支持 flexFlow 属性。</p>
</body>
</html>
定义和用法
flexFlow 属性是 flexDirection 和 flexWrap 属性的速记属性。
flexDirection 属性规定灵活项目的方向。
flexWrap 属性规定灵活项目是否拆行或拆列。
注意:如果元素不是灵活的项目,则 flexFlow 属性不起作用。
浏览器支持
![]()
![]()
![]()
![]()
![]()
Firefox、Opera 和 Chrome 支持 flexFlow 属性。
语法
返回 flexFlow 属性:
object.style.flexFlow
设置 flexFlow 属性:
object.style.flexFlow = "flex-direction flex-wrap|initial|inherit"
属性值
| 值 | 描述 |
|---|---|
| flex-direction | 可能的值: row row-reverse column column-reverse initial inherit 默认值是 "row"。 规定灵活项目的方向。 |
| flex-wrap | 可能的值: nowrap wrap wrap-reverse initial inherit 默认值是 "nowrap"。 规定灵活项目是否拆行或拆列。 |
| initial | 设置该属性为它的默认值。请参阅 initial。 |
| inherit | 从父元素继承该属性。请参阅 inherit。 |
技术细节
| 默认值: | row nowrap |
|---|---|
| 返回值: | 字符串,表示元素的 flex-flow 属性。 |
| CSS 版本 | CSS3 |
相关文章
CSS 参考手册:flex-flow 属性
HTML DOM STYLE 参考手册:flex 属性
HTML DOM STYLE 参考手册:flexBasis 属性
HTML DOM STYLE 参考手册:flexDirection 属性
HTML DOM STYLE 参考手册:flexGrow 属性
HTML DOM STYLE 参考手册:flexShrink 属性
HTML DOM STYLE 参考手册:flexWrap 属性
Style 对象
Style 对象