Skip to content

Commit c2fabd6

Browse files
committed
Better docs layout for narrow screens
Backport of 9b8793a2df508ac5f2cc7eeee72720488fa6f422 This uses a css grid instead of hard-coded 230px margins, and makes it so the ToC only takes up 40% of the screen, so you don't have to scroll past the entire thing for longer tables (like in the release notes)
1 parent 9c60947 commit c2fabd6

2 files changed

Lines changed: 48 additions & 20 deletions

File tree

docs/docs/4.0b1/_static/pydoctheme.css

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ div.related h3 {
7171
}
7272

7373
div.related li.right {
74-
float: right;
7574
margin-right: 5px;
7675
}
7776

7877
div.sphinxsidebar {
79-
width: 230px;
8078
overflow-wrap: break-word;
8179
}
8280

@@ -113,7 +111,6 @@ div.sphinxsidebar ul {
113111
margin: 10px;
114112
padding: 0;
115113
color: var(--secondary-link-color);
116-
margin: 10px;
117114
list-style: none;
118115
}
119116

@@ -548,10 +545,6 @@ div.sphinxsidebar ul {
548545
}
549546

550547

551-
div.bodywrapper {
552-
margin-left: 230px;
553-
}
554-
555548
aside.footnote > .label {
556549
display: inline;
557550
}
@@ -565,34 +558,52 @@ div.documentwrapper {
565558
width: 100%;
566559
}
567560

561+
div.document {
562+
display: grid;
563+
grid-template: 1fr min-content / 12rem minmax(0,1fr);
564+
}
565+
568566
/* On screens that are less than 700px wide remove anything non-essential
569567
- the sidebar, the gradient background, ... */
570568
@media screen and (max-width: 700px) {
569+
div.document {
570+
display: grid;
571+
grid-template: 30vh min-content / 100%;
572+
}
571573
div.sphinxsidebar {
572574
font-size: 16px;
573575
width: 100%;
574576
height: auto;
575577
position: relative;
578+
/* To separate the "side"bar from the content below */
579+
border-bottom: 1px solid;
580+
border-color: var(--sidebar-border-color);
576581
}
577-
div.bodywrapper {
582+
583+
/* Reduce margins to save space */
584+
div.sphinxsidebar ul ul, div.sphinxsidebar ul, div.bodywrapper, div.content {
578585
margin-left: 0;
579586
}
580587

588+
div.sphinxsidebar h3, div.sphinxsidebar h4 {
589+
margin-top: 0;
590+
}
581591

582592
div.sphinxsidebar ul {
583593
flex-basis: content;
584594
flex-wrap: wrap;
585595
}
586596
div.sphinxsidebarwrapper {
587597
display: flex;
598+
gap: 1em;
599+
justify-content: space-between;
588600
}
589601
div.sphinxsidebarwrapper > h3:nth-child(5) {
590602
display: none;
591603
}
592-
div#searchbox {
604+
#searchbox {
593605
display: none !important;
594606
}
595-
div.content {margin-left: 0;}
596607
div.body {
597608
padding: 1rem;
598609
}
@@ -613,6 +624,9 @@ div.documentwrapper {
613624

614625
/* On print media remove anything non-essential. */
615626
@media print {
627+
div.document {
628+
display: block;
629+
}
616630
.inline-search {
617631
display: none;
618632
}

site/docs/4.0b1/_static/pydoctheme.css

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ div.related h3 {
7171
}
7272

7373
div.related li.right {
74-
float: right;
7574
margin-right: 5px;
7675
}
7776

7877
div.sphinxsidebar {
79-
width: 230px;
8078
overflow-wrap: break-word;
8179
}
8280

@@ -113,7 +111,6 @@ div.sphinxsidebar ul {
113111
margin: 10px;
114112
padding: 0;
115113
color: var(--secondary-link-color);
116-
margin: 10px;
117114
list-style: none;
118115
}
119116

@@ -548,10 +545,6 @@ div.sphinxsidebar ul {
548545
}
549546

550547

551-
div.bodywrapper {
552-
margin-left: 230px;
553-
}
554-
555548
aside.footnote > .label {
556549
display: inline;
557550
}
@@ -565,34 +558,52 @@ div.documentwrapper {
565558
width: 100%;
566559
}
567560

561+
div.document {
562+
display: grid;
563+
grid-template: 1fr min-content / 12rem minmax(0,1fr);
564+
}
565+
568566
/* On screens that are less than 700px wide remove anything non-essential
569567
- the sidebar, the gradient background, ... */
570568
@media screen and (max-width: 700px) {
569+
div.document {
570+
display: grid;
571+
grid-template: 30vh min-content / 100%;
572+
}
571573
div.sphinxsidebar {
572574
font-size: 16px;
573575
width: 100%;
574576
height: auto;
575577
position: relative;
578+
/* To separate the "side"bar from the content below */
579+
border-bottom: 1px solid;
580+
border-color: var(--sidebar-border-color);
576581
}
577-
div.bodywrapper {
582+
583+
/* Reduce margins to save space */
584+
div.sphinxsidebar ul ul, div.sphinxsidebar ul, div.bodywrapper, div.content {
578585
margin-left: 0;
579586
}
580587

588+
div.sphinxsidebar h3, div.sphinxsidebar h4 {
589+
margin-top: 0;
590+
}
581591

582592
div.sphinxsidebar ul {
583593
flex-basis: content;
584594
flex-wrap: wrap;
585595
}
586596
div.sphinxsidebarwrapper {
587597
display: flex;
598+
gap: 1em;
599+
justify-content: space-between;
588600
}
589601
div.sphinxsidebarwrapper > h3:nth-child(5) {
590602
display: none;
591603
}
592-
div#searchbox {
604+
#searchbox {
593605
display: none !important;
594606
}
595-
div.content {margin-left: 0;}
596607
div.body {
597608
padding: 1rem;
598609
}
@@ -613,6 +624,9 @@ div.documentwrapper {
613624

614625
/* On print media remove anything non-essential. */
615626
@media print {
627+
div.document {
628+
display: block;
629+
}
616630
.inline-search {
617631
display: none;
618632
}

0 commit comments

Comments
 (0)