From 73d44503fdcb2210796ed43e45748798ac443596 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Mon, 15 Mar 2021 17:42:44 -0600 Subject: [PATCH] Use logical CSS properties Replace phyiscal properties (top/bottom/left/right) with logical properties (start/end) that can be used in non-LTR contexts (e.g., content in Arabic or Hebrew). Based on the CSS Logical Properties and Values Level 1 specification, currently an Editor's Draft [1]. Referencing MDN, all major browsers except Internet Explorer support the margin, padding, and border properties. [1]: https://drafts.csswg.org/css-logical/ Signed-off-by: Tim Crawford --- src/theme/css/chrome.css | 65 ++++++++++++++++++++++++--------------- src/theme/css/general.css | 21 +++++++------ src/theme/css/print.css | 2 +- 3 files changed, 53 insertions(+), 35 deletions(-) diff --git a/src/theme/css/chrome.css b/src/theme/css/chrome.css index 0a7c530a..14f85070 100644 --- a/src/theme/css/chrome.css +++ b/src/theme/css/chrome.css @@ -37,9 +37,9 @@ a > .hljs { display: flex; flex-wrap: wrap; background-color: var(--bg); - border-bottom-color: var(--bg); - border-bottom-width: 1px; - border-bottom-style: solid; + border-block-end-color: var(--bg); + border-block-end-width: 1px; + border-block-end-style: solid; } #menu-bar.sticky, .js #menu-bar-hover-placeholder:hover + #menu-bar, @@ -56,7 +56,7 @@ a > .hljs { height: var(--menu-bar-height); } #menu-bar.bordered { - border-bottom-color: var(--table-border-color); + border-block-end-color: var(--table-border-color); } #menu-bar i, #menu-bar .icon-button { position: relative; @@ -160,7 +160,7 @@ a > .hljs { } .nav-wrapper { - margin-top: 50px; + margin-block-start: 50px; display: none; } @@ -174,10 +174,12 @@ a > .hljs { } .previous { + /* Only Firefox supports flow-relative values */ float: left; } .next { + /* Only Firefox supports flow-relative values */ float: right; right: var(--page-padding); } @@ -237,7 +239,7 @@ pre > .buttons :hover { background-color: var(--theme-hover); } pre > .buttons i { - margin-left: 8px; + margin-inline-start: 8px; } pre > .buttons button { cursor: inherit; @@ -274,7 +276,7 @@ pre > code { } pre > .result { - margin-top: 10px; + margin-block-start: 10px; } /* Search */ @@ -285,8 +287,14 @@ pre > .result { mark { border-radius: 2px; - padding: 0 3px 1px 3px; - margin: 0 -3px -1px -3px; + padding-block-start: 0; + padding-block-end: 1px; + padding-inline-start: 3px; + padding-inline-end: 3px; + margin-block-start: 0; + margin-block-end: -1px; + margin-inline-start: -3px; + margin-inline-end: -3px; background-color: var(--search-mark-bg); transition: background-color 300ms linear; cursor: pointer; @@ -298,14 +306,17 @@ mark.fade-out { } .searchbar-outer { - margin-left: auto; - margin-right: auto; + margin-inline-start: auto; + margin-inline-end: auto; max-width: var(--content-max-width); } #searchbar { width: 100%; - margin: 5px auto 0px auto; + margin-block-start: 5px; + margin-block-end: 0; + margin-inline-start: auto; + margin-inline-end: auto; padding: 10px 16px; transition: box-shadow 300ms ease-in-out; border: 1px solid var(--searchbar-border-color); @@ -321,20 +332,23 @@ mark.fade-out { .searchresults-header { font-weight: bold; font-size: 1em; - padding: 18px 0 0 5px; + padding-block-start: 18px; + padding-block-end: 0; + padding-inline-start: 5px; + padding-inline-end: 0; color: var(--searchresults-header-fg); } .searchresults-outer { - margin-left: auto; - margin-right: auto; + margin-inline-start: auto; + margin-inline-end: auto; max-width: var(--content-max-width); - border-bottom: 1px dashed var(--searchresults-border-color); + border-block-end: 1px dashed var(--searchresults-border-color); } ul#searchresults { list-style: none; - padding-left: 20px; + padding-inline-start: 20px; } ul#searchresults li { margin: 10px 0px; @@ -347,7 +361,10 @@ ul#searchresults li.focus { ul#searchresults span.teaser { display: block; clear: both; - margin: 5px 0 0 20px; + margin-block-start: 5px; + margin-block-end: 0; + margin-inline-start: 20px; + margin-inline-end: 0; font-size: 0.8em; } ul#searchresults span.teaser em { @@ -423,13 +440,13 @@ ul#searchresults span.teaser em { @media only screen and (min-width: 620px) { #sidebar-toggle-anchor:checked ~ .page-wrapper { transform: none; - margin-left: var(--sidebar-width); + margin-inline-start: var(--sidebar-width); } } .chapter { list-style: none outside none; - padding-left: 0; + padding-inline-start: 0; line-height: 2.2em; } @@ -459,7 +476,7 @@ ul#searchresults span.teaser em { .chapter li > a.toggle { cursor: pointer; display: block; - margin-left: auto; + margin-inline-start: auto; padding: 0 10px; user-select: none; opacity: 0.68; @@ -476,7 +493,7 @@ ul#searchresults span.teaser em { .chapter li.chapter-item { line-height: 1.5em; - margin-top: 0.6em; + margin-block-start: 0.6em; } .chapter li.expanded > a.toggle div { @@ -499,7 +516,7 @@ ul#searchresults span.teaser em { .section { list-style: none outside none; - padding-left: 20px; + padding-inline-start: 20px; line-height: 1.9em; } @@ -532,7 +549,7 @@ ul#searchresults span.teaser em { padding: 2px 20px; line-height: 25px; white-space: nowrap; - text-align: left; + text-align: start; cursor: pointer; color: inherit; background: inherit; diff --git a/src/theme/css/general.css b/src/theme/css/general.css index 0956b906..180b0e96 100644 --- a/src/theme/css/general.css +++ b/src/theme/css/general.css @@ -48,13 +48,13 @@ h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { .hide-boring .boring { display: none; } .hidden { display: none !important; } -h2, h3 { margin-top: 2.5em; } -h4, h5 { margin-top: 2em; } +h2, h3 { margin-block-start: 2.5em; } +h4, h5 { margin-block-start: 2em; } .header + .header h3, .header + .header h4, .header + .header h5 { - margin-top: 1em; + margin-block-start: 1em; } h1:target::before, @@ -65,7 +65,7 @@ h5:target::before, h6:target::before { display: inline-block; content: "ยป"; - margin-left: -30px; + margin-inline-start: -30px; width: 30px; } @@ -74,13 +74,14 @@ h6:target::before { https://bugs.webkit.org/show_bug.cgi?id=218076 */ :target { + /* Safari does not support logical properties */ scroll-margin-top: calc(var(--menu-bar-height) + 0.5em); } .page { outline: 0; padding: 0 var(--page-padding); - margin-top: calc(0px - var(--menu-bar-height)); /* Compensate for the #menu-bar-hover-placeholder */ + margin-block-start: calc(0px - var(--menu-bar-height)); /* Compensate for the #menu-bar-hover-placeholder */ } .page-wrapper { box-sizing: border-box; @@ -96,8 +97,8 @@ h6:target::before { padding: 0 5px 50px 5px; } .content main { - margin-left: auto; - margin-right: auto; + margin-inline-start: auto; + margin-inline-end: auto; max-width: var(--content-max-width); } .content p { line-height: 1.45em; } @@ -147,8 +148,8 @@ blockquote { padding: 0 20px; color: var(--fg); background-color: var(--quote-bg); - border-top: .1em solid var(--quote-border); - border-bottom: .1em solid var(--quote-border); + border-block-start: .1em solid var(--quote-border); + border-block-end: .1em solid var(--quote-border); } kbd { @@ -166,7 +167,7 @@ kbd { :not(.footnote-definition) + .footnote-definition, .footnote-definition + :not(.footnote-definition) { - margin-top: 2em; + margin-block-start: 2em; } .footnote-definition { font-size: 0.9em; diff --git a/src/theme/css/print.css b/src/theme/css/print.css index 27d05e92..3272bd01 100644 --- a/src/theme/css/print.css +++ b/src/theme/css/print.css @@ -8,7 +8,7 @@ #page-wrapper.page-wrapper { transform: none; - margin-left: 0px; + margin-inline-start: 0px; overflow-y: initial; }