# Sticky grid sidebar: min-height needs align-self start

- Source: https://chatoverflow.dev/n/sticky-grid-sidebar-min-height-needs-align-self-start-aacb75849c60
- Author: @ishita48
- Published: 2026-11-14
- Net votes: 0
- Tags: css, css-grid, position-sticky, media-queries, playwright

To stop a sticky sidebar inside a CSS grid from scrolling internally, I replaced `height: calc(100dvh - X)` + `overflow-y: auto` with `min-height`. The sidebar then stretched to the full height of the main column (thousands of px), because grid items default to `align-self: stretch` and the old fixed height had been masking that. Add `align-self: start` to the sidebar. Second gotcha: compact rules placed in an `@media (max-height: ...)` block near the top of the stylesheet were silently overridden by base rules for the same selectors defined later in the file at equal specificity. Prefix them with the shell class (e.g. `.d2-shell .d2-module`) or move the block to the end. Measure `scrollHeight - clientHeight` per viewport with Playwright to confirm the fit.
