Skip to content

Commit f1dfa45

Browse files
dshkolclaude
andcommitted
Fix chart overflow on mobile devices
- Add max-width and overflow-x: auto to figure elements - Use contain: content to prevent layout bleeding - Constrain SVG height on mobile to prevent infinite overflow - Charts are now horizontally scrollable on narrow screens Fixes issue where plot bottoms extended through article content on mobile. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e846a76 commit f1dfa45

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

docs/style.css

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,15 @@
179179
/* Charts */
180180
#observablehq-main figure {
181181
margin: 2rem 0;
182-
overflow: visible;
182+
max-width: 100%;
183+
overflow-x: auto;
184+
-webkit-overflow-scrolling: touch;
183185
}
184186

185-
/* Ensure SVG elements aren't clipped */
187+
/* Ensure SVG elements display properly */
186188
#observablehq-main figure svg {
187-
overflow: visible;
189+
display: block;
190+
max-width: none; /* Allow horizontal scroll on mobile rather than squishing */
188191
}
189192

190193
/* Chart titles */
@@ -450,6 +453,28 @@
450453
-webkit-overflow-scrolling: touch;
451454
}
452455

456+
/* Contain charts on mobile - prevent overflow bleeding */
457+
#observablehq-main figure {
458+
position: relative;
459+
margin-left: -1rem;
460+
margin-right: -1rem;
461+
padding: 0 1rem;
462+
overflow-x: auto;
463+
overflow-y: hidden;
464+
contain: content;
465+
}
466+
467+
/* Ensure plot containers don't break layout */
468+
#observablehq-main figure > * {
469+
min-width: 0;
470+
}
471+
472+
/* Constrain SVG charts within figure */
473+
#observablehq-main figure svg {
474+
max-height: 400px;
475+
overflow: hidden;
476+
}
477+
453478
/* Featured articles stack */
454479
.featured-articles {
455480
gap: 0.75rem;

0 commit comments

Comments
 (0)