From c8f0e7a8e1de1680e6d5f6bfe860155347dfc2df Mon Sep 17 00:00:00 2001 From: GBKS Date: Fri, 8 Jan 2021 09:47:22 +0100 Subject: [PATCH] Another attempt at fixing header spacing for deep links This approach only applies to h2 to h6. Uses hidden elements for spacing (instead of padding/margin) with a negative offset (as Johns solution did before). Fixes the issue that the hidden element blocks interaction with the home page banner with relative positioning and z-index. --- _sass/minima/_base.scss | 2 +- _sass/minima/_home-banner.scss | 5 ++++ _sass/minima/_layout.scss | 44 +++++++++++++++++++++++++++------- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/_sass/minima/_base.scss b/_sass/minima/_base.scss index 3ba6ff213..1d507d28b 100644 --- a/_sass/minima/_base.scss +++ b/_sass/minima/_base.scss @@ -50,7 +50,7 @@ h1, h2, h3, h4, h5, h6, p, blockquote, pre, ul, ol, dl, figure, %vertical-rhythm { - margin-bottom: $spacing-unit / 2; + margin-top: $spacing-unit / 2; } hr { diff --git a/_sass/minima/_home-banner.scss b/_sass/minima/_home-banner.scss index b23725cd4..f766174b2 100644 --- a/_sass/minima/_home-banner.scss +++ b/_sass/minima/_home-banner.scss @@ -138,8 +138,13 @@ .home-banner-info { display: flex; justify-content: center; + max-width: 1680px; + margin-left: auto; + margin-right: auto; background-color: #f4f4f4; padding: 5px 15px; + position: relative; + z-index: 1; .home-banner-info-wrapper { width: 100%; diff --git a/_sass/minima/_layout.scss b/_sass/minima/_layout.scss index 3b5d01e05..7a0d1daff 100644 --- a/_sass/minima/_layout.scss +++ b/_sass/minima/_layout.scss @@ -176,23 +176,51 @@ article.guide h1 { .post-content, article.guide { - h1, h2, h3 { + h1 { + margin-top: $spacing-unit * 1; + + @include media-query(medium-up) { + margin-top: $spacing-unit * 2; + } + } + + h2, h3, h4, h5, h6 { margin-top: 0; - padding-top: $spacing-unit * 1; + + &::before { + display: block; + content: ''; + width: 0; + visibility: hidden; + position: relative; + z-index: -1; + pointer-events: none; + } + } + + h2, h3 { + &::before { + height: $spacing-unit * 1; + } @include media-query(medium-up) { - margin-top: 0; - padding-top: $spacing-unit * 2; + &::before { + height: $spacing-unit * 3; + margin-top: -$spacing-unit * 2; + } } } h4, h5, h6 { - margin-top: 0; - padding-top: $spacing-unit * 0.5; + &::before { + height: $spacing-unit * 1.5; + margin-top: -$spacing-unit 1.5; + } @include media-query(medium-up) { - margin-top: 0; - padding-top: $spacing-unit * 2; + &::before { + height: $spacing-unit * 1; + } } }