flex

W3C CSS Snapshot 2026

Set flex-grow, flex-shrink, and flex-basis together on one item.

On this page

Syntax and values

Value or syntaxWhat it does
initial / 0 1 autoStarts from its normal size, can shrink, and does not grow.
auto / 1 1 autoStarts from its normal size and can grow or shrink.
none / 0 0 autoKeeps its normal size. It can neither grow nor shrink through flex sizing.
1Sets grow and shrink to 1. Browsers use a 0% basis for the one-number form.
10em / min-contentA basis by itself sets both grow and shrink to 1.
2 1 / 2 120pxWith two values, the second is the shrink factor if it is a number, or the basis if it is a size.
2 1 120pxGrow is 2, shrink is 1, and the starting size is 120px.

Try the example

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>flex example</title>
  <style>
.layout { display: flex; width: min(100%, 320px); border: 2px solid teal; box-sizing: border-box; }
.layout > div { padding: 8px 12px; background: #def5f5; color: #123; border: 1px solid #81b9b5; box-sizing: border-box; }
.layout > div { flex: 1; }
.layout .first { flex: 2; }
  </style>
</head>
<body>
<div class="layout">
  <div class="first">A</div>
  <div class="second">B</div>
  <div>C</div>
</div>
</body>
</html>

What to expect The tiles divide the available space, and A gets a larger share. Change A to flex: none and compare.

Official references