Skip to content

Shrinking a Sticky Admin Header from 180px to 70px

Adityo Guni Waluyo

A sticky admin header sits 180px tall at 1440px. Two flex rows, a forced role-bar row, and meta ellipsis shrink it to 70px with no horizontal overflow.

TL;DR

A sticky header eating half the viewport is a layout problem, not a spacing one. Rebuilding it as two flex rows with a shared baseline, a truncated meta line, and a full-width role bar cut the height from 180px to about 70px. Measure the header in the DOM first, then trim padding and type after.

I opened the document page of the admin manual at a width of 1440px. A single measurement line in the browser Console showed the header height: around 180px. Since that header is sticky, the number is not a one-time viewport cost. The element sticks to the top of the container and stays visible as long as the page keeps scrolling [1]. Nearly half the viewport height was gone before the first sentence of the document became readable.

My first guess was proportion. I cut the header's vertical padding from 0.85rem and 0.75rem down to 0.4rem and 0.35rem, the bottom margin from 1.1rem to 0.8rem, and forced the title to 1.05rem. The header number did drop, but nowhere near a height that is reasonable for a document read for hours.

The height did not belong to a single property, as it turned out. The 180px figure was an accumulation: the title, the meta line, and the chips each took their own row, on top of oversized block padding. The fix was structural, not cosmetic. I rebuilt the header into two rows, and one key property let the meta line be truncated without forcing overflow.

Measure the header height before touching any CSS

Before touching any declaration, I read the starting condition straight from the DOM. In the browser Console on that page, run:

document.querySelector('.content > header').getBoundingClientRect().height

Expected output: a number around 180. The selector .content > header is the one used in the generate_manual.mjs file, so the measurement and the CSS change hit the same element.

I used that value as the baseline and as the reason for measuring first. As long as the header is sticky, every pixel of its height is a permanent vertical cost [1]. Adding 20px here is the same as cutting 20px of reading space across a page that can run several screens long.

Restructure the header into two flex rows

First, turn .content > header into flex with a shared baseline for title, meta, and chips.

.content > header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .15rem .9rem;
}

A nowrap value on flex-wrap stacks every item on a single row so they can spill out of the container. The wrap keyword prevents overflow by letting items move to the next line [5]. A baseline alignment makes the title, meta, and chips stand on the same baseline instead of stacking vertically on top of one another.

Second, force the role bar down to the second row.

.content > header > .rolebar {
  flex: 1 0 100%;
  padding: 0;
}
.rolebar-label {
  font-size: 0.64rem;
}
.rolebar button {
  font-size: 0.74rem;
}

The value flex: 1 0 100% gives that item a full flex-basis, so it starts its own row and the wrap lands exactly there [5]. I removed the role bar's padding and shrank its type so the second row stays slim.

Third, make the meta line truncatable. Without this step, the other changes still produce overflow.

.content > header .meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74rem;
}

text-overflow does not force anything to happen. The ellipsis only appears when overflow: hidden and white-space: nowrap are also set [2]. What decides everything is min-width: 0: the automatic minimum size of a flex item is min-content, so long text refuses to shrink and the ellipsis never shows up without that override [4].

Fourth, I trimmed the remaining density. The chips became 0.68rem with padding 0.1rem 0.45rem, and the title stayed at 1.05rem. Small adjustments only start to show effect here, because the row structure is already right.

Verify the result at four screen widths

Repeat the same measurement from the beginning.

document.querySelector('.content > header').getBoundingClientRect().height

Expected output at 1440px: around 70. The result in this project was 69 to 71px, and the single-line official document page dropped to 37px.

Then test horizontal overflow at each target width.

document.documentElement.scrollWidth <= window.innerWidth

Expected output: true, at 1440, 1024, 900, and 768. If the result is false, some item still refuses to shrink, and the cause is almost always meta without min-width: 0.

General standards have their own requirement as well. Content must stay readable at a width of 320 CSS pixels, equivalent to a 1280-pixel viewport at 400% zoom, without needing scrolling in two dimensions at once (SC 1.4.10 Reflow [3]). On narrow screens this header wraps into three rows, and no horizontal overflow shows up.

My final decision: two rows with a shared baseline, the role bar forced down through a full flex-basis, and meta allowed to be truncated. The padding and type adjustments still ran, just with small values. What moved the number from 180px to 70px was the row arrangement.

Sources

[1] MDN Web Docs, CSS position documentation

[2] MDN Web Docs, text-overflow documentation

[3] W3C WAI, SC 1.4.10 Reflow documentation

[4] MDN Web Docs, min-width documentation

[5] MDN Web Docs, flex-wrap documentation

Related articles