Flex as 'flexible' and box as 'container' is a beautiful approach to the responsive layouts. A container which adjusts its content with the change in device screens.
The display property has many values, you must have heard of inline, inline-block, block, and none. Let me introduce you to a very interesting value called flex, a value which changes many things for you.
Flexbox is another design technique that gives us arrangement control that no different CSS strategy can create. It exceeds expectations at 'miniaturized scale design': the capacity to adjust, arrange, and convey space among things in a compartment, or modify a component's width or stature to best fill the accessible space.
In Responsive Web Design, the width accessible differs as the viewport width changes sizes. This leads to unintended content wrapping, particularly when the content is longer than intended for or the space available is less to fit the div/containers.
Before Flexbox we used to work with CSS Media Queries to adjust layout at specific ranges(breakpoints) to resolve issues with content wrapping. Be that as it may, Media Queries don't consider the length of the content itself, they react to a specific width or height. This used to result in a lot of code to manage for different screen sizes.
Flexbox, on the other hand, solves this problem by empowering us to exploit the space accessible and afterward wrap content when it's most certainly not. This auto-change conduct isn't just helpful, however, enhances viability since we don't need to depend on breakpoint to physically modify the styling. The precedent above shows this conduct: show the area mark neighboring the title if enough space is accessible, and adjust the area name to one side beneath the title if adequate space isn't accessible.
The flexbox container enables a flex context for all its direct children.
Below are the properties of Flex
1. Flex-direction, 2. Flex-wrap, 3. Justify-content, 4. Align-items, 5. Align-content
1. Flex-direction : defines the main-axis, thus defining the direction flex items are placed in the flex container. Flexbox is a single-direction layout concept. Consider flex things as primarily laying out either in horizontal rows or vertical columns.
2. Flex-wrap : The default value of flex-wrap for class row is wrap so they will try to fit onto one line but you can change that and allow items to wrap as needed with following values.
3. Justify-content : It disperses extra free space left over when either all the flex elements/items on a line are unbendable, or are flexible but have achieved their most extreme size. It likewise applies some power over the arrangement of things when they overflow the line.
4. Align-items : This defines the default behavior for how flex things are spread out along the cross axis on the current line. Consider it the justify-content version for the cross-axis.