Skip to content

Commit 614576d

Browse files
committed
contain code-block overflow with bordered horizontal scroll on mobile
Long code lines can overflow narrow screens and trigger horizontal page scrolling. For code, wrapping/breaking tokens is undesirable because it hurts copy/paste and readability fidelity. Style `pre` as an explicit container (background, border, radius, padding) and enable `overflow-x: auto` so overflow is contained inside the code block instead of the page. The container styling, especially the border, is intentional and important: it makes the block read as a distinct container, which makes it easier to recognize when it is scrollable. Style inline `code` to match the visual language, and reset `pre code` background and padding so nested code does not get double styling. Result: on mobile, overflowing code stays unbroken and scrolls within a clearly visible bounded container; on desktop, behavior remains normal when no overflow occurs.
1 parent d36a799 commit 614576d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

assets/sass/main.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ big {
2727
small {
2828
font-size: 70%;
2929
}
30+
pre {
31+
background-color: rgb(247, 243, 239);
32+
border: 1px solid #c5bbb0;
33+
border-radius: 0.5em;
34+
padding: 1em;
35+
overflow-x: auto;
36+
}
37+
code {
38+
background-color: rgb(247, 243, 239);
39+
padding: 0.1em 0.3em;
40+
border-radius: 0.25em;
41+
}
42+
pre code {
43+
background-color: transparent;
44+
padding: 0;
45+
}
3046
div.feature-matrix {
3147
table {
3248
border-collapse: collapse;

0 commit comments

Comments
 (0)