The flex-flow
property
is a property of the Flexible Box Layout.
It is a shorthand for flex-direction
and flex-wrap
.
The flex-direction
property sets the direction of the flexible items.
The flex-wrap
property sets whether to wrap the flexible items.
flex-flow: flex-direction flex-wrap|initial|inherit;
flex-flow |
Yes | 11.0 | Yes | Yes | Yes |
<!DOCTYPE html>
<html>
<head>
<style>
#main {<!-- www. j a v a 2 s. c o m-->
width: 200px;
height: 200px;
border: 1px solid black;
display: -webkit-flex; /* Safari */
-webkit-flex-flow: row-reverse wrap; /* Safari 6.1+ */
display: flex;
flex-flow: row wrap;
}
#main div {
width: 50px;
height: 50px;
}
</style>
</head>
<body>
<div id="main">
<div style="background-color:red;">A</div>
<div style="background-color:blue;">B</div>
<div style="background-color:tomato;">C</div>
<div style="background-color:pink;">D</div>
<div style="background-color:grey;">E</div>
<div style="background-color:green;">F</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<style>
.flex-container {<!-- ww w .jav a2 s. c o m-->
padding: 0;
margin: 0;
list-style: none;
-ms-box-orient: horizontal;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
}
h1 {
padding-left: .5em;
}
.shorthand {
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-flex-direction: row;
flex-direction: row;
}
.longhand {
-webkit-flex-flow: wrap row;
flex-flow: wrap row;
}
.longhand li {
background: blue;
}
.flex-item {
background: red;
padding: 5px;
width: 100px;
height: 100px;
margin: 10px;
line-height: 100px;
color: white;
}
</style>
</head>
<body>
<h1>flex-wrap: wrap; flex-direction: row;</h1>
<ul class="flex-container longhand">
<li class="flex-item">1</li>
<li class="flex-item">2</li>
<li class="flex-item">3</li>
<li class="flex-item">4</li>
</ul>
<h1>flex-flow: row wrap;</h1>
<ul class="flex-container shorthand">
<li class="flex-item">1</li>
<li class="flex-item">2</li>
<li class="flex-item">3</li>
<li class="flex-item">4</li>
</ul>
</body>
</html>