Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Shorthand CSS property for flex-direction and flex-wrap
The CSS flex-flow property is a shorthand property that combines flex-direction and flex-wrap into a single declaration. This property allows you to control both the direction of flex items and whether they wrap to new lines.
Syntax
selector {
flex-flow: flex-direction flex-wrap;
}
Possible Values
| Value | Description |
|---|---|
flex-direction |
Sets the direction: row, row-reverse, column, column-reverse |
flex-wrap |
Sets wrapping: nowrap, wrap, wrap-reverse |
Example: Column Direction with Wrapping
The following example uses flex-flow: column wrap to arrange items vertically with wrapping −
<!DOCTYPE html>
<html>
<head>
<style>
.mycontainer {
display: flex;
background-color: orange;
flex-flow: column wrap;
height: 300px;
}
.mycontainer > div {
background-color: white;
text-align: center;
line-height: 40px;
font-size: 25px;
width: 100px;
margin: 5px;
}
</style>
</head>
<body>
<h1>Quiz</h1>
<div class="mycontainer">
<div>Q1</div>
<div>Q2</div>
<div>Q3</div>
<div>Q4</div>
<div>Q5</div>
<div>Q6</div>
<div>Q7</div>
<div>Q8</div>
<div>Q9</div>
</div>
</body>
</html>
An orange container with white quiz boxes (Q1-Q9) arranged vertically in columns. When the container height is exceeded, items wrap to create new columns.
Example: Row Direction with No Wrapping
Here's an example using flex-flow: row nowrap for horizontal arrangement without wrapping −
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
background-color: lightblue;
flex-flow: row nowrap;
width: 400px;
}
.container > div {
background-color: white;
text-align: center;
padding: 20px;
margin: 5px;
border: 1px solid #333;
flex: 1;
}
</style>
</head>
<body>
<div class="container">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
</body>
</html>
A light blue container with three white boxes arranged horizontally in a single row, each taking equal width without wrapping.
Conclusion
The flex-flow property provides a convenient shorthand for setting both flex direction and wrapping behavior. It's equivalent to setting flex-direction and flex-wrap separately but in a single, more concise declaration.
Advertisements
