Fix code block width overflow causing navigation menu to shrink #472 by DhanashreePetare · Pull Request #816 · git/git.github.io · GitHub
Skip to content

Fix code block width overflow causing navigation menu to shrink #472 - #816

Open
DhanashreePetare wants to merge 1 commit into
git:masterfrom
DhanashreePetare:fix-codeblock-width-issue-472
Open

DhanashreePetare wants to merge 1 commit into
git:masterfrom
DhanashreePetare:fix-codeblock-width-issue-472

Conversation

@DhanashreePetare

Copy link
Copy Markdown

Summary

Fixes #472 - Code blocks with very long lines now scroll horizontally instead of expanding the entire page width, which was causing the navigation menu to become excessively narrow.

Problem

Code blocks containing long lines (e.g., lengthy git commands or URLs) were expanding beyond the content area, causing:

  • Navigation menu to be squeezed into a very narrow column
  • Poor rendering on mobile screens
  • Horizontal scrolling required for the entire page

This was particularly noticeable in Rev News editions 66 and 68.

Solution

Modified CSS for pre and pre.sh_sourceCode elements to:

  • Changed white-space: pre-wrap to white-space: pre (prevents line wrapping)
  • Added overflow-x: auto (enables horizontal scrolling within code blocks only)
  • Added max-width: 100% (constrains code blocks to content width)

Key Improvements Over Previous Attempt (#668)

  • ✅ No font size changes - readability maintained across all screen sizes
  • ✅ Only affects code blocks - no impact on other page elements
  • ✅ Minimal, focused CSS changes (6 lines added/modified)
  • ✅ Works seamlessly on desktop and mobile devices

Files Changed

  • css/main.css - Updated code block styling (7 lines modified)

@mjaix

mjaix commented Jan 1, 2026

Copy link
Copy Markdown
Contributor

@DhanashreePetare

Copy link
Copy Markdown
Author

This branch has not been deployed

No deployments
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.

Ensure code-blocks take-up fixed width that's lesser than the content width

3 participants