Skip to content

Commit ace6dbf

Browse files
authored
Fix badge table layout overflow on mobile (#1364) (#1486)
The achievement tables have a nested DEFAULT/BRONZE/SILVER/GOLD tier table in the last column. On phones that column is squeezed and pushes the row off-screen, so SILVER and GOLD end up out of view. Below 768px each badge row now stacks into a card, giving every cell, including the nested tier table, the full viewport width. The tier cells are shrunk so all four columns fit without clipping. Desktop is unchanged because the rules live in a max-width media query. Closes #1364
1 parent 498c3ff commit ace6dbf

1 file changed

Lines changed: 83 additions & 1 deletion

File tree

styles/githubbadge.css

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,4 +551,86 @@ body.dark-mode .themed-text {
551551
padding-left: 20px;
552552
padding-top: 40px;
553553
object-fit: scale-down; /* Ensure the aspect ratio is maintained */
554-
}
554+
}
555+
556+
/* Issue #1364: on mobile the badge tables overflow horizontally. The last
557+
column holds a nested DEFAULT/BRONZE/SILVER/GOLD tier table, and crammed
558+
into a narrow column on a phone it pushes the row off-screen. Below 768px
559+
each badge row becomes a stacked card, so every cell (including the nested
560+
tier table) gets the full viewport width instead of overflowing. The three
561+
primary tables are direct children of .container; the tier tables live
562+
inside a <td>, so the child combinator leaves them untouched. Desktop is
563+
unchanged. */
564+
@media screen and (max-width: 768px) {
565+
.container > table,
566+
.container > table > tbody,
567+
.container > table > tbody > tr,
568+
.container > table > tbody > tr > td {
569+
display: block;
570+
width: 100%;
571+
box-sizing: border-box;
572+
}
573+
574+
.container > table > thead {
575+
display: none;
576+
}
577+
578+
.container > table > tbody > tr {
579+
margin: 0 0 16px;
580+
border: 1px solid #ddd;
581+
border-radius: 8px;
582+
padding: 12px;
583+
overflow-x: auto; /* a very wide tier table scrolls inside its own card */
584+
}
585+
586+
.container > table > tbody > tr > td {
587+
border: none;
588+
text-align: center;
589+
padding: 6px 4px;
590+
}
591+
592+
/* All three primary tables share Badge / Name / How to get as columns 1-3,
593+
so labelling by position is safe. The 4th column exists only on the
594+
achievement tables. */
595+
.container > table > tbody > tr > td:nth-child(2)::before {
596+
content: "Name: ";
597+
font-weight: 700;
598+
}
599+
600+
.container > table > tbody > tr > td:nth-child(3)::before {
601+
content: "How to get: ";
602+
font-weight: 700;
603+
}
604+
605+
.container > table > tbody > tr > td:nth-child(4)::before {
606+
content: "Needed amount";
607+
font-weight: 700;
608+
display: block;
609+
margin-bottom: 6px;
610+
}
611+
612+
.container > table > tbody > tr > td:first-child img {
613+
max-width: 96px;
614+
height: auto;
615+
}
616+
617+
/* The nested tier table now sits in a full-width cell, so center it and
618+
let it size to its content rather than stretching the card. */
619+
.container > table td table {
620+
width: auto;
621+
margin: 8px auto 0;
622+
}
623+
624+
/* Shrink the tier cells so all four columns (DEFAULT/BRONZE/SILVER/GOLD)
625+
fit within the card instead of clipping GOLD off the right edge. */
626+
.container > table td table th,
627+
.container > table td table td {
628+
padding: 3px 4px;
629+
font-size: 11px;
630+
}
631+
632+
.container > table td table img {
633+
max-width: 44px;
634+
height: auto;
635+
}
636+
}

0 commit comments

Comments
 (0)