Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make anchors have top-padding #2202

Merged
merged 2 commits into from
Nov 15, 2018
Merged

Conversation

baronfel
Copy link
Contributor

This padding makes it so that a clicked anchor is visible underneath the top sticky nav. I am not at all sure that this is the correct way to handle this situation.

Description

TODO

  • [] Is this the appropriate sizing?
  • [] Is there a constant that would otherwise be appropriate?
  • [] Is this padding appropriate for all .content .anchors?

This padding makes it so that a clicked anchor is visible underneath the top sticky nav.
@matthid
Copy link
Member

matthid commented Nov 15, 2018

I am not at all sure that this is the correct way to handle this situation.

@JarnoNijboer @florianbader is it?

@florianbader
Copy link
Contributor

florianbader commented Nov 15, 2018

@JarnoNijboer @florianbader is it?

Looks good to me.

@sliepie
Copy link
Contributor

sliepie commented Nov 15, 2018

Me also, an increase to 70px would make it perfect

@matthid matthid merged commit ef694b9 into fsprojects:release/next Nov 15, 2018
@baronfel baronfel deleted the patch-3 branch November 15, 2018 20:08
@matthid
Copy link
Member

matthid commented Nov 18, 2018

I just tested this on staging and found the following "glitch":

image

You cannot (easily) mark the text below the purple box. I'm not sure if this is fixable or how. Anyone an idea?

@baronfel
Copy link
Contributor Author

Instead of padding, margin could be used to create space above the text but below the upper section content?

Or the z-indexof anchors could be set lower than the x index of the page content so that the page content would remain selectable in this situation?

@sliepie
Copy link
Contributor

sliepie commented Nov 19, 2018

Margin doesn't work unfortunately. We could however fix it with some js:

Below should work, it's untested

(function() {
    if (document.location.hash) {
        document.body.scrollBy(0, 70);
    }
}());

@florianbader
Copy link
Contributor

Using the following on the anchor works for me, but we would need to create the anchor separate from the header link. I can create a PR for that later if someone isn't faster.

.anchor { display: block; position: relative; top: -70px; }

<a name="Reference-a-paket-group" class="anchor"></a> <a href="#Reference-a-paket-group">Reference a paket group</a>

@sliepie
Copy link
Contributor

sliepie commented Nov 19, 2018

Delete comment with the :target selector solution works, but has the same issue with text selection as the current one.

@sliepie
Copy link
Contributor

sliepie commented Nov 19, 2018

This one works for me: inspired by @florianbader solution, i've used ::before selector to create the dummy anchor:

Corresponding PR: #2209

.content .anchor::before {
    display: block;
    content: "";
    height: 50px; /* Fixed menu height */
    margin: -50px 0 0;
    visibility: hidden;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Website] anchor link titles are hidden under stick top nav
4 participants