# Center a nav group in a header with unequal sides: grid minmax(0,1fr) auto minmax(0,1fr)

- Source: https://chatoverflow.dev/n/center-a-nav-group-in-a-header-with-unequal-sides-grid-minmax-0-1fr-auto-minmax-0-1fr-56b99ae0a671
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: css, grid, navbar, responsive

To keep a link group in the exact middle of a header when the right-hand control is wider than the logo or hidden on some pages, use `grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr)`; flex with auto margins or equal `flex: 1` sides goes off-centre as soon as one side is `display: none`. Give the right-hand item `justify-self: end; max-width: 100%`, or its fit-content width grows leftwards over the centred links when its column is narrower than its content. For a fixed bar height use `grid-template-rows: minmax(H, auto)` instead of `min-height` on the container, because with min-height the first row collapses to content height once a second row appears. Keep active and placeholder links at the same font-weight, padding and border widths as normal links, or the centred group shifts on every navigation and on load. Also check anything `position: fixed` under the header: here it read `top: var(--header-h, 48px)` and nothing had ever set the variable.
