CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



flex-flow

Flex-Flow is a CSS property that combines two other properties, Flex-Direction and Flex-Wrap, into one shorthand property. It is used to control the direction and wrapping of flex items within a flex container.

The Flex-Direction property determines the main axis of the flex container and the direction in which flex items are laid out. It can be set to row, row-reverse, column, or column-reverse. The default value is row.

The Flex-Wrap property determines whether flex items should wrap or not when they exceed the width or height of the flex container. It can be set to nowrap, wrap, or wrap-reverse. The default value is nowrap.

By combining these two properties into one shorthand property, Flex-Flow allows you to set both properties at once. The syntax for Flex-Flow is:

flex-flow: <flex-direction> <flex-wrap>;

For example, if you want to create a flex container with a column layout and wrap the flex items, you can use the following code:

.container {
  display: flex;
  flex-flow: column wrap;
}

This will create a flex container with a column layout and wrap the flex items when they exceed the height of the container.

Here are some examples of how to use Flex-Flow:

Example 1: Row Layout with No Wrapping

.container {
  display: flex;
  flex-flow: row nowrap;
}

This will create a flex container with a row layout and no wrapping. The flex items will be laid out in a single row and will not wrap to the next line.

Example 2: Column Layout with Wrapping

.container {
  display: flex;
  flex-flow: column wrap;
}

This will create a flex container with a column layout and wrapping. The flex items will be laid out in a single column and will wrap to the next line when they exceed the height of the container.

Example 3: Row-Reverse Layout with No Wrapping

.container {
  display: flex;
  flex-flow: row-reverse nowrap;
}

This will create a flex container with a row-reverse layout and no wrapping. The flex items will be laid out in a single row in reverse order and will not wrap to the next line.

Example 4: Column-Reverse Layout with Wrapping

.container {
  display: flex;
  flex-flow: column-reverse wrap;
}

This will create a flex container with a column-reverse layout and wrapping. The flex items will be laid out in a single column in reverse order and will wrap to the next line when they exceed the height of the container.

Flex-Flow is a powerful CSS property that allows you to control the direction and wrapping of flex items within a flex container. By combining Flex-Direction and Flex-Wrap into one shorthand property, it makes it easier to write and read CSS code.

References

Activity