The flex property in CSS is the combination of flex-grow, flex-shrink, and flex-basis property. It is used to set the length of flexible items. The flex property is much responsive and mobile friendly. It is easy to positioning child elements and the main container.
The margin doesn’t collapse with the content margins. Order of any element can be easily changed without editing the HTML section. But few times we have an unequal width of the element also that time you can design the whole things in the CSS section.
Note: Elements width depend on the other elements and screen of your window in this case.
Example 1: Here you will see the two types of width flexbox is design by using CSS.
Example 2: In this example you will see 4 items each of them having unequal width compare to each other.
- What are the differences between flex-basis and width in Flexbox ?
- How to set space between the flexbox ?
- Advance CSS layout with flexbox
- How to align flexbox columns left and right using CSS ?
- Flexbox utilities in bootstrap with examples
- How to make flexbox children 100% height of their parent using CSS?
- How to vertically align text inside a flexbox using CSS?
- How to vertically and horizontally align flexbox to center ?
- How to place content under fixed flexbox navigation bar ?
- HTML width/height Attribute vs CSS width/height Property
- CSS | max-width Property
- CSS | min-width Property
- p5.js | width variable
- How to set up fixed width for
- How to set div width to fit content using CSS ?
- CSS | Height and Width
- Web API | DOMRect width property
- CSS | column-width Property
- HTML | <pre> width Attribute
- HTML | <img> width Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.