Skip to content

fix: align wide docs layout to main content area, not viewport#11

Merged
hugolytics merged 4 commits into
mainfrom
fix/docs-wide-layout-sidebar-overflow
Mar 12, 2026
Merged

fix: align wide docs layout to main content area, not viewport#11
hugolytics merged 4 commits into
mainfrom
fix/docs-wide-layout-sidebar-overflow

Conversation

@hugolytics
Copy link
Copy Markdown
Member

Fixes the vLLM example page sliding behind the left sidebar on wide desktop viewports, and tightens the max-width so the embed has comfortable margins.

Root cause

The .docs-story-embed and .docs-example-page--wide rules used 100vw-based widths with margin-left: 50% + translateX(-50%) to center wide elements. This broke at desktop widths for two reasons:

  1. Starlight unlayered base styles override margin-left inside @layer starlight.components, resolving it to 0px instead of 50%.
  2. With margin-left: 0, the translateX(-50%) centres the element on the left edge of .sl-markdown-content rather than the centre of main -- causing it to extend 360px behind the left sidebar.

Fix

  • Remove margin-left: 50% and encode the full centering correction in transform alone, using Starlight CSS variables (--sl-sidebar-width, --sl-content-width, --sl-content-pad-x).
  • Cap max-width at 80rem instead of 112rem so the element has ~100px breathing room on each side within main at 1800px viewport.
  • Inside .docs-example-page--wide the embed fills its container (width: 100%; transform: none) since the outer wrapper already handles layout.

Verified at 1800px viewport

Before: .docs-example-page--wide at left=-41.5 (behind sidebar right=300), width=1448px filling 97% of main with no margins.
After: .docs-example-page--wide at left=403, right=1683, width=1280px with 103px symmetric margins inside main (left=300, right=1785).

Closes #8

The .docs-story-embed and .docs-example-page--wide rules used 100vw-based
widths with margin-left: 50% + translateX(-50%) to center wide elements.
This broke at desktop widths because:

1. Starlight's unlayered styles override margin-left inside @layer
   starlight.components, resolving it to 0px instead of 50%.
2. With margin-left=0, translateX(-50%) centres the element on the left
   edge of .sl-markdown-content, not on main's centre — causing the
   element to extend ~360px behind the left sidebar.

Fix: remove margin-left: 50% and compute the full correction in transform.
The translateX now shifts by (-50% + half the content-column width), which
places the element centre exactly at the main content area centre regardless
of sidebar presence. Width is capped to 100vw - sidebar - 4rem so it never
overflows into the sidebar. Inside .docs-example-page--wide the embed just
fills its container (width: 100%; transform: none).

Closes #8
- Add ?expandable to iframe src so the viewer's own expand button is shown
- Remove the <a class=docs-story-popout> anchor from the MDX
- Remove .docs-story-popout CSS rules and the padding-top on .docs-story-frame
  that only existed to make room for the external button
@hugolytics hugolytics merged commit b8700c1 into main Mar 12, 2026
3 checks passed
@hugolytics hugolytics deleted the fix/docs-wide-layout-sidebar-overflow branch March 12, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: vLLM example page slides under left sidebar on wide desktop widths

1 participant