• Resolved gugax

    (@gugax)


    Hi,

    So, I am trying to fix how my anchors work in the Twenty Seventeen theme, as it seems there is some kind of bug.

    # Context
    My website:
    1. is a single static page (actually I have multiple pages but they are displayed as single page);
    2. it contains a navigation menu, right below the header image;
    3. the menu stays fixed to top of the screen when I scroll down trough the page;
    4. the menu links jump to the <H1> element that I defined for each page (using HTML anchor in the element’s configuration);
    5. I have child theme to add/replace CSS.

    # Problem
    When clicking to jump to specific anchor, the <H1> element associated to that anchor goes to top of the page (position: 0), not possible to see it as it stays behind the menu.

    # Expectation
    When clicking to jump to the anchor, the <H1> element associated to that anchor goes to top of the page right below the menu, so it is visible.

    # Question
    How can I use CSS to fix this in the Twenty Seventeen theme?
    I know that i have to use something like top and position properties in CSS, but I don’t know which class should I use to replace this wrong behaviour.

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Actually, you can’t fix it with CSS. The browser controls the position of the anchor, and it varies by browser and the length of the page. You might be able to add some Javascript to fix it, or let your menu scroll.

    By the way, one page sites are bad for SEO and user experience.

    Thread Starter gugax

    (@gugax)

    Hi @joyously ,

    Thank you for your answer.

    I managed to do it using JavaScript, but its still in prototype mode as I need to test on mobile and devices with different screen size. I think even with Javascript I will have the issue on different screens as I’m using static value in pixels to move the <h1> below navigation.

    Regarding one page site, my website is for a specific group of people (not a company) and users will use it more in mobile (prediction) thats why i choose a single page.
    But thanks for the additional hint ??

    • This reply was modified 4 years, 1 month ago by gugax.
    • This reply was modified 4 years, 1 month ago by gugax.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Anchors’ is closed to new replies.