Skip to content

Element gets hidden behind fixed header after scroll #580

@R0lin

Description

@R0lin

Hi! I'm experiencing an issue when using Driver.js on a page that has a fixed header.

Scenario:
When the element to be highlighted is located further down the page, Driver.js scrolls to it as expected. However, if the page includes a fixed header (position: fixed; top: 0), the scroll behavior does not account for the header’s height. As a result, the highlighted element ends up partially or fully hidden behind the header — but only when the target element is taller than the viewport.

Reproduction conditions:

  • The page has a fixed header (height: 65px).
  • The target element is taller than the viewport height (height > 100vh).
  • Driver.js scrolls the element to the top of the viewport, but part of it is hidden behind the header.

Example header CSS:

.header-fixed .header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 100;
    background-color: #ffffff;
    height: 65px;
    padding: 0;
    box-shadow: 0px 10px 30px 0px rgba(82, 63, 105, 0.05);
}

Current behavior:

  • Driver.js scrolls the target element to the top of the viewport.
  • If the element is tall, it becomes partially hidden behind the fixed header.

Expected behavior:

  • Scrolling should position the top of the target element below the fixed header, taking its height into account (e.g., scrollY - headerHeight).

Driver.js configuration used:

Driver.driver({
    showProgress: true,
    showButtons: ['next', 'previous', 'close'],
    overlayClickBehavior: 'close',
    allowClose: false,
    stagePadding: 10,
    allowKeyboardControl: false,
    nextBtnText: 'Next',
    prevBtnText: 'Back',
    doneBtnText: 'Done'
});

Live demo:
Here is a live CodePen reproducing the issue (target element is taller than the viewport):
CodePen Live Demo

Possible solution:
A possible fix could be:

  • Allowing a scrollOffset or scrollPaddingTop configuration.
  • Respecting scroll-margin-top CSS if set.
  • Or exposing a way to customize scroll behavior manually.

Thanks for your great work on Driver.js! Let me know if a more detailed example is helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions