Skip to content

Commit e5f77aa

Browse files
authored
Merge pull request #1077 from mattheww/2019-10_scroll-margin
Add CSS `scroll-margin-top` to headings which contain link targets.
2 parents 21d8f39 + 86a368b commit e5f77aa

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/theme/css/chrome.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ a > .hljs {
4545
position: relative;
4646
padding: 0 8px;
4747
z-index: 10;
48-
line-height: 50px;
48+
line-height: var(--menu-bar-height);
4949
cursor: pointer;
5050
transition: color 0.5s;
5151
}
@@ -73,7 +73,7 @@ a > .hljs {
7373
}
7474

7575
html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-container {
76-
transform: translateY(-60px);
76+
transform: translateY(calc(-10px - var(--menu-bar-height)));
7777
}
7878

7979
.left-buttons {
@@ -88,7 +88,7 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
8888
display: inline-block;
8989
font-weight: 200;
9090
font-size: 20px;
91-
line-height: 50px;
91+
line-height: var(--menu-bar-height);
9292
text-align: center;
9393
margin: 0;
9494
flex: 1;
@@ -446,7 +446,7 @@ ul#searchresults span.teaser em {
446446
.theme-popup {
447447
position: absolute;
448448
left: 10px;
449-
top: 50px;
449+
top: var(--menu-bar-height);
450450
z-index: 1000;
451451
border-radius: 4px;
452452
font-size: 0.7em;

src/theme/css/general.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ h4 a.header:target::before {
4545
width: 30px;
4646
}
4747

48+
h1 a.header:target,
49+
h2 a.header:target,
50+
h3 a.header:target,
51+
h4 a.header:target {
52+
scroll-margin-top: calc(var(--menu-bar-height) + 0.5em);
53+
}
54+
4855
.page {
4956
outline: 0;
5057
padding: 0 var(--page-padding);

src/theme/css/variables.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
--sidebar-width: 300px;
66
--page-padding: 15px;
77
--content-max-width: 750px;
8+
--menu-bar-height: 50px;
89
}
910

1011
/* Themes */

0 commit comments

Comments
 (0)