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.
flex: flex-grow flex-shrink flex-basis|auto|initial|inherit;
- flex-grow: A number that specify, how much items will grow relative to the rest of the flexible items.
- flex-shrink: A number that specify, how much items will shrink relative to the rest of the flexible items.
- flex-basis: It sets the length of items. Legal values of flex basis are: auto, inherit, or a number followed by %, em, px or any other length unit.
- Google Chrome 29.0, 21.0 -webkit-
- Internet Explorer 11.0, 10.0 -ms-
- Firefox 28.0, 18.0 -moz-
- Safari 9.0, 6.1 -webkit-
- Opera 17.0
- CSS | flex-wrap property
- CSS | flex-grow Property
- CSS | flex-shrink Property
- CSS | flex-flow Property
- CSS | flex-direction Property
- CSS | flex-basis Property
- What is the difference between inline-flex and inline-block in CSS?
- CSS | Ordering Flex Items
- HTML | DOM Style flex Property
- Bootstrap 4 | Flex
- What are the differences between flex-basis and width in Flexbox ?
- How to put items underneath each other flex box in Bootstrap 4 ?
- How to Right-align flex item?
- CSS | transition-property Property
- How to override the CSS properties of a class using another CSS class ?
- Difference between bootstrap.css and bootstrap-theme.css
- CSS | table-layout Property
- CSS | text-align Property
- CSS | border-top-width Property
- CSS | isolation Property
Supported Browser: The browser supported by flex property are listed below:
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.