Layout bug · Fix guide

Sticky Header Covering Content? How to Fix It

Updated October 31, 2026

A sticky header covers content because position: fixed removes it from the page flow, so the page starts underneath it. Add top padding equal to the header height, and set scroll-padding-top so anchor links land below it. On phones, reduce the header height, since it takes space from a small screen.

Quick diagnosis

  • Top of every page hidden: the page has no offset for a fixed header.
  • Anchor links land under the header: scroll-padding-top is missing.
  • Fine on desktop, overlaps on mobile: the header wraps to two lines and grows.
  • A gap or overlap when a banner appears: the announcement bar changes the header height.

Causes and fixes

1

The page has no space for a fixed header

Most common

position: fixed lifts the header out of the page flow, so the content below moves up to fill its place. The first heading ends up hidden behind the header.

Fix: Add padding-top to the body equal to the header height, or use position: sticky, which keeps the header in the page flow.

2

Anchor links scroll under the header

Table of contents and "jump to" links scroll the target to the very top of the window, which is exactly where the header sits. Visitors land just past the heading they asked for.

Fix: Set html { scroll-padding-top: 90px } using your header height. It works on all modern browsers and needs no JavaScript.

3

The header grows on small screens

A logo and menu that fit on one line at desktop width wrap to two lines on a phone. A fixed offset written for desktop then falls short.

Fix: Store the height in a CSS variable, set it in each breakpoint, and use it for both the padding and the scroll offset.

4

An announcement bar changes the height

Sale banners and cookie notices sit above the header. When one appears or is dismissed, the total height changes and the page offset no longer matches.

Fix: Put the banner inside the sticky container, so both move together, or measure the height with a small ResizeObserver and update the variable.

5

The header takes up too much of a phone screen

A tall header plus a banner and a sticky add-to-cart bar can leave a small part of the screen for content, and landscape phones make this worse.

Fix: Shrink the header on scroll, hide the banner once the visitor scrolls, and keep the total sticky height under about 20% of the screen.

6

A parent stops `position: sticky` working

Sticky elements stop sticking when a parent has overflow: hidden or overflow: auto. Developers then swap to fixed as a workaround, and the overlap begins.

Fix: Remove the overflow rule from the parent, or use overflow: clip, which doesn't break sticky positioning.

How to find it on your site

  1. 1

    Load the page from the top

    Check whether the first heading is fully visible below the header at 375px, 768px and 1440px.

  2. 2

    Click an anchor link

    Use any table of contents or #section link, and confirm the heading lands below the header.

  3. 3

    Trigger the banner

    Show and dismiss the cookie and announcement bars, then check the offset again.

  4. 4

    Rotate the phone

    Landscape cuts the screen height, so a header that looks fine upright can fill half the view.

Fixes by platform

Shopify

Most themes have a sticky header setting. If you added a custom announcement bar, set it in the theme's header group so the theme can measure the total height.

WordPress

Header builder plugins add their own sticky behaviour on top of the theme. Turn on only one of them. Add the scroll offset under Appearance → Customize → Additional CSS.

Wix and Squarespace

Use the built-in "freeze header" option and leave spacing on the first section. Check the result in the mobile editor, which keeps its own layout.

Custom code

Prefer position: sticky over fixed. Set --header-height once, then use it for scroll-padding-top and any full-height sections.

Frequently asked questions

How do I stop a fixed header from covering content?

Add top padding to the page equal to the header height. Using position sticky avoids the problem, because the header stays in the page flow and pushes content down.

Why do my anchor links scroll past the heading?

The browser scrolls the target to the top of the window, behind your header. Add scroll-padding-top to the html element, using your header height, and links will land below it.

Why is position sticky not working?

A parent with overflow hidden, auto or scroll stops it, and it also needs a top value set. Check each parent element in DevTools, or use overflow clip on the parent.

Are sticky headers bad for mobile?

They help when short and hurt when tall. Keep the total sticky height small, shrink the header on scroll, and avoid stacking a banner, a header and a bottom bar on one screen.