13 September 2024

To create CSS flex columns with equal width except for the last one, you can use this combination of flexbox properties.

Source code viewer
  1. .container {
  2. display: flex;
  3. }
  4.  
  5. .container > div {
  6. flex: 1;
  7. }
  8.  
  9. .container > div:last-child {
  10. /* Replace auto with a fixed width. */
  11. flex: 0 0 auto;
  12. }
Programming Language: CSS