Skip to content

Commit 97235d1

Browse files
spookylukeyintrot
andauthored
Fix incorrect breakpoints that cause clipping around 875px (#174)
As well as fixing the case for the default `theme_page_width`, it works with customised values too (which was my main motivation for this!) Analysis/explanation: - The issue was a `max-width: 875px` block that came after a `max-width: 870px` block. - If you are below 875px but not 870px, then you get properties from 875 block only. This gives a very strange 5 pixel window for certain changes, which must be a mistake. - Some properties were defined in both 875 and 870 block, and were pointless because these are always overridden by 875 (since if you are below 870 you are always below 875, and the 875 block comes second in the source). - So I've combined all these into one block, keeping the 875 blocks values where they differ. In many cases there was just duplication which I removed. - I changed the breakpoint width to `{{ theme_page_width }}`, which gives (almost) the correct behaviour. There is still a slight clipping issue, which is caused by the width of the scrollbar, and the way that browsers include that in width calculations - an issue which, after a lot of Googling, doesn't appear to have any nice solutions. One way would be to just add, say, 20px to `theme_page_width` but this is not convenient for us to do, since the value we have has units. So for now, I'd recommend just living with this small glitch - it is barely noticeable, and due to margins the page switches layout before any main text is obscured. - I've fixed the sidebar breakpoint similarly for `fixed_sidebar` option. This was at a `min-width: 876px` breakpoint. Since we can't do 1px adjustment calculations (as above), I inverted the logic, creating an additional section in the `max-width: {{ theme_page_width }}` block instead. I've tested and this seems to work fine. Co-authored-by: introt <[email protected]>
1 parent 5bb4411 commit 97235d1

File tree

1 file changed

+24
-70
lines changed

1 file changed

+24
-70
lines changed

alabaster/static/alabaster.css_t

+24-70
Original file line numberDiff line numberDiff line change
@@ -566,67 +566,14 @@ a:hover tt, a:hover code {
566566
}
567567

568568

569-
@media screen and (max-width: 870px) {
570-
571-
div.sphinxsidebar {
572-
display: none;
573-
}
574-
575-
div.document {
576-
width: 100%;
577-
578-
}
579-
580-
div.documentwrapper {
581-
margin-left: 0;
582-
margin-top: 0;
583-
margin-right: 0;
584-
margin-bottom: 0;
585-
}
586-
587-
div.bodywrapper {
588-
margin-top: 0;
589-
margin-right: 0;
590-
margin-bottom: 0;
591-
margin-left: 0;
592-
}
593-
594-
ul {
595-
margin-left: 0;
596-
}
597-
598-
li > ul {
599-
/* Matches the 30px from the "ul, ol" selector above */
600-
margin-left: 30px;
601-
}
602-
603-
.document {
604-
width: auto;
605-
}
606-
607-
.footer {
608-
width: auto;
609-
}
610-
611-
.bodywrapper {
612-
margin: 0;
613-
}
614-
615-
.footer {
616-
width: auto;
617-
}
618-
619-
.github {
620-
display: none;
621-
}
622-
623-
624-
569+
{%- if theme_fixed_sidebar|lower == 'true' %}
570+
div.sphinxsidebar {
571+
position: fixed;
572+
margin-left: 0;
625573
}
574+
{%- endif %}
626575

627-
628-
629-
@media screen and (max-width: 875px) {
576+
@media screen and (max-width: {{ theme_page_width }}) {
630577

631578
body {
632579
margin: 0;
@@ -636,14 +583,19 @@ a:hover tt, a:hover code {
636583
div.documentwrapper {
637584
float: none;
638585
background: {{ theme_base_bg }};
586+
margin-left: 0;
587+
margin-top: 0;
588+
margin-right: 0;
589+
margin-bottom: 0;
639590
}
640591

641592
div.sphinxsidebar {
642593
display: block;
643594
float: none;
644-
width: 102.5%;
595+
width: unset;
645596
{%- if theme_fixed_sidebar|lower == 'true' %}
646597
margin: -20px -30px 20px -30px;
598+
position: static;
647599
{%- else %}
648600
margin: 50px -30px -20px -30px;
649601
{%- endif %}
@@ -680,8 +632,14 @@ a:hover tt, a:hover code {
680632

681633
div.body {
682634
min-height: 0;
635+
min-width: auto; /* fixes width on small screens, breaks .hll */
683636
padding: 0;
684637
}
638+
639+
.hll {
640+
/* "fixes" the breakage */
641+
width: max-content;
642+
}
685643

686644
.rtd_doc_footer {
687645
display: none;
@@ -695,23 +653,19 @@ a:hover tt, a:hover code {
695653
width: auto;
696654
}
697655

698-
.footer {
699-
width: auto;
700-
}
701-
702656
.github {
703657
display: none;
704658
}
705-
}
706659

707-
{%- if theme_fixed_sidebar|lower == 'true' %}
708-
@media screen and (min-width: 876px) {
709-
div.sphinxsidebar {
710-
position: fixed;
660+
ul {
711661
margin-left: 0;
712662
}
663+
664+
li > ul {
665+
/* Matches the 30px from the "ul, ol" selector above */
666+
margin-left: 30px;
667+
}
713668
}
714-
{%- endif %}
715669

716670

717671
/* misc. */

0 commit comments

Comments
 (0)