From f0fb0f30de5607e34e81fbe08e7f9e4905870965 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 25 Sep 2019 12:31:56 +0200 Subject: [PATCH] Jumping to headlines now accounts for the fixed header's height --- .../install/files/lib/system/html/toc/HtmlToc.class.php | 4 ++++ wcfsetup/install/files/style/ui/article.scss | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/wcfsetup/install/files/lib/system/html/toc/HtmlToc.class.php b/wcfsetup/install/files/lib/system/html/toc/HtmlToc.class.php index 7a525e4625..436b1c1945 100644 --- a/wcfsetup/install/files/lib/system/html/toc/HtmlToc.class.php +++ b/wcfsetup/install/files/lib/system/html/toc/HtmlToc.class.php @@ -52,6 +52,10 @@ class HtmlToc { // the need of user interactions, making it a somewhat cumbersome experience. KISS. $id = "{$idPrefix}-{$id}"; + $classes = $hElement->getAttribute('class'); + if (!empty($classes)) $classes .= ' '; + $hElement->setAttribute('class', $classes . 'anchorFixedHeader'); + $hElement->setAttribute('id', $id); $headings[] = new HtmlTocItem(intval(substr($hElement->tagName, 1, 1)), $id, $title); diff --git a/wcfsetup/install/files/style/ui/article.scss b/wcfsetup/install/files/style/ui/article.scss index 53ba8d59cb..c43220087a 100644 --- a/wcfsetup/install/files/style/ui/article.scss +++ b/wcfsetup/install/files/style/ui/article.scss @@ -60,6 +60,13 @@ .articleLikeButtons:not(:empty) { margin-top: 20px; } + + .anchorFixedHeader:target::before { + content: ""; + display: block; + height: 50px; + margin-top: -50px; + } } .articleAboutAuthor { -- 2.20.1