On this page
flex
Prev: `display` | Up: layout | Next: `justify-content`
Rel: layout, Display & Layout Guide
Ref: MDN Web Docs — flex
Tags: #public #web #css #properties #layout #tier/core
Syntax & Overview
flex: <grow> <shrink> <basis>;
Shorthand controlling how a flex item grows and shrinks along the main axis.
- Initial:
0 1 auto| Inherited: No | Animatable: Yes
Notes & Best Practices
- Shorthand for
flex-grow flex-shrink flex-basis:flex: 1expands to1 1 0%(equal widths); addmin-width: 0on flex children containing long text/code so they can actually shrink!
Example
.row { display: flex; gap: 1rem; }
.row > .main { flex: 1 1 0%; min-width: 0; }
.row > .aside { flex: 0 0 18rem; }
Linked from
Related notes
- tuts/css/properties/layout/display Linked here; links to this page; shared tags: #css, #layout, #properties, #tier, #web
- tuts/css/properties/layout/justify-content Linked here; links to this page; shared tags: #css, #layout, #properties, #tier, #web
- tuts/css/properties/layout Linked here; links to this page; shared tags: #css, #layout, #properties, #web
- tuts/css/properties/display_and_layout Linked here; shared tags: #css, #layout, #properties, #web
- tuts/css/properties/layout/align-items shared tags: #css, #layout, #properties, #tier, #web
- tuts/css/properties/layout/float shared tags: #css, #layout, #properties, #tier, #web
- tuts/css/properties/layout/gap shared tags: #css, #layout, #properties, #tier, #web
- tuts/css/properties/layout/grid-template-columns shared tags: #css, #layout, #properties, #tier, #web
- tuts/css/properties/box_model/aspect-ratio shared tags: #css, #properties, #tier, #web
- tuts/css/properties/box_model/box-sizing shared tags: #css, #properties, #tier, #web