fix code flow overflow and add responsive design fix (#3229)

## Description
Fixes code block overflow issues by adding proper CSS overflow handling
and responsive design: Code blocks overflow and don't scale properly
#3228

## Changes Made to _base.scss
- Added `overflow-x`: auto to enable horizontal scrolling for long code
lines
- Added `white-space: pre` to preserve code formatting while allowing
horizontal scrolling
- Added `word-wrap: normal` to prevent wrapping of long lines
- Added `-webkit-overflow-scrolling: touch` for smooth iOS scrolling
- Added responsive font sizes for different breakpoints (576px, 400px,
and 768px)
- Applied fixes to `pre`, `code`, and `figure.highlight` elements

## Related Issue
Closes  #3228

---------

Signed-off-by: George Araújo <george.gcac@gmail.com>
Co-authored-by: George Araújo <george.gcac@gmail.com>
This commit is contained in:
Yana Nesterenko 2025-11-16 20:38:44 -05:00 committed by GitHub
parent 4086784bc7
commit 8086c57b79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -891,6 +891,18 @@ footer.sticky-bottom {
// Rouge Color Customization // Rouge Color Customization
figure.highlight { figure.highlight {
margin: 0 0 1rem; margin: 0 0 1rem;
// Responsive code block container
overflow-x: auto;
-webkit-overflow-scrolling: touch;
pre {
// Ensure code blocks can scroll horizontally
white-space: pre;
word-wrap: normal;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
} }
pre { pre {
@ -899,6 +911,12 @@ pre {
border-radius: 6px; border-radius: 6px;
padding: 6px 12px; padding: 6px 12px;
// Responsive behavior for code blocks
overflow-x: auto;
-webkit-overflow-scrolling: touch;
white-space: pre;
word-wrap: normal;
pre, pre,
code { code {
background-color: transparent; background-color: transparent;
@ -913,6 +931,10 @@ code {
background-color: var(--global-code-bg-color); background-color: var(--global-code-bg-color);
border-radius: 3px; border-radius: 3px;
padding: 3px 3px; padding: 3px 3px;
// Inline code should wrap
white-space: normal;
word-wrap: break-word;
} }
// Transitioning Themes // Transitioning Themes
@ -1092,6 +1114,62 @@ nav[data-toggle="toc"] {
height: 0; height: 0;
top: 0; top: 0;
} }
/* Responsive code blocks for mobile */
pre {
font-size: 0.875rem;
padding: 8px 10px;
margin: 0.5rem 0;
}
figure.highlight {
margin: 0.5rem 0;
pre {
font-size: 0.875rem;
padding: 8px 10px;
}
}
code {
font-size: 0.875rem;
padding: 2px 4px;
}
}
/* Extra small screens */
@media (max-width: 400px) {
pre {
font-size: 0.8rem;
padding: 6px 8px;
}
figure.highlight {
pre {
font-size: 0.8rem;
padding: 6px 8px;
}
}
code {
font-size: 0.8rem;
padding: 1px 3px;
}
}
/* Medium screens - optimize for tablets */
@media (min-width: 577px) and (max-width: 768px) {
pre {
font-size: 0.9rem;
padding: 8px 12px;
}
figure.highlight {
pre {
font-size: 0.9rem;
padding: 8px 12px;
}
}
} }
.featured-posts { .featured-posts {