DEV Community

Cover image for What is CSS Flexbox
Eljan Simuratli
Eljan Simuratli

Posted on

What is CSS Flexbox

CSS flexboxes are modern css layout that help us to order elements vertical and horizontal.

Why flexbox?

It is easier to make responsive our website with flexbox.
Flex structure is simple.
Flexbox supported by all browsers today.
Browser

How to use Flexbox:
There are 2 main item in flexbox. First Container , second Items.
flex
flex

Display
Using display:flex we make our container flexible.

.container{display: flex /* or inline-flex */}
Enter fullscreen mode Exit fullscreen mode

Flex Direction

![flexcontainer}(https://miro.medium.com/max/490/1*s-G7MS21vXkAgI1gTBzeBg.png)

Flex direction used to determine how items arranged in layout(horizontal or vertical) and applied to the container element.

gif

.container{
display: flex /* or inline-flex*/
flex-direction: row /* or  | row-reverse | column | column-reverse */;
}
Enter fullscreen mode Exit fullscreen mode
  • row (default): standard layout from left to right
  • row-reverse: reverse layout from right to left
  • column: From top to bottom layout
  • column-reverse: From bottom to top layout

Flex-wrap

Flex-wrap mostly used for creating responsive layouts. The flex-wrap property is specified as a single keyword chosen from the list of values below.

  • nowrap (default): All elements are in 1 row.This is the default value.
  • wrap: The flex items break into multiple lines.
  • wrap-reverse: Behaves the same as wrap but it have reverse order.

Justify-content

It defines the alignment along the main axis.
justify

Align-items

It help us alignment of items in y-axis.

align items

align

For more dev posts : Link

Top comments (0)