Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS flex-flow Property

Posted in CSS Tutorial
Updated on Oct 02, 2024
By Mari Selvan
👁️ 26 - Views
⏳ 4 mins
💬 1 Comment
CSS flex-flow Property

Photo Credit to CodeToFun

🙋 Introduction

The flex-flow property in CSS is a shorthand property that combines the flex-direction and flex-wrap properties.

It defines the direction in which flex items are placed in the flex container and whether they should wrap onto multiple lines.

This property is useful for creating flexible and responsive layouts without needing to write multiple lines of CSS.

💡 Syntax

The syntax for the flex-flow property is as follows:

Syntax
Copied
Copy To Clipboard
element {
  flex-flow: flex-direction flex-wrap;
}
  • flex-direction: Specifies the direction of the flexible items.
  • flex-wrap: Specifies whether the flexible items should wrap or not.

🎛️ Default Value

The default value for the flex-flow property is row nowrap, which means the flex items are placed in a single line in the row direction.

🏠 Property Values

  • flex-direction:
    • row: Items are placed in a row (default).
    • row-reverse: Items are placed in a row, but in reverse order.
    • column: Items are placed in a column.
    • column-reverse: Items are placed in a column, but in reverse order.
  • flex-wrap:
    • nowrap: All flex items will be on one line (default).
    • wrap: Flex items will wrap onto multiple lines, from top to bottom.
    • wrap-reverse: Flex items will wrap onto multiple lines, from bottom to top.

📄 Example

In this example, we'll create a flex container with items that wrap onto multiple lines and are arranged in a column.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS flex-flow Example</title>
  <style>
    .container {
      display: flex;
      flex-flow: column wrap;
      height: 200px;
    }
    .item {
      width: 100px;
      height: 50px;
      background-color: lightcoral;
      margin: 5px;
    }
  </style>
</head>
<body>
  <h1>Flex Container with Custom Flex Flow</h1>
  <div class="container">
    <div class="item">Item 1</div>
    <div class="item">Item 2</div>
    <div class="item">Item 3</div>
    <div class="item">Item 4</div>
    <div class="item">Item 5</div>
    <div class="item">Item 6</div>
  </div>
</body>
</html>

🖥️ Browser Compatibility

The flex-flow property is well-supported across all modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. This ensures consistent behavior of flex layouts across different platforms.

🎉 Conclusion

The flex-flow property is a convenient shorthand for controlling the flow of flex items within a container.

By combining the flex-direction and flex-wrap properties, you can efficiently manage the layout and wrapping behavior of your flex items. This property helps in creating flexible and responsive designs with minimal CSS code, making it an essential tool for modern web development.

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy