Advanced Header Scroll for Bricks
Makes a header sticky and changes how it looks and moves as the page scrolls. Transparent over a hero, a different background and colours once scrolled, shrinking, and hiding when the visitor scrolls down then returning as soon as they scroll up.
Open the live demo (sticky, shrinking, hides on scroll) · Open the hero demo (transparent over a picture, then white)
Adding it
- Open your header template and add Header Scroll anywhere inside it. It has no visible output; it only controls how the header behaves.
- Choose a Position. Nothing sticks until you do.
- Pick the looks and movements below.
Because it is an element inside the header template, the settings apply wherever that header is used. To give a single page an ordinary header, set Turn off on pages that contain to a class such as .no-sticky-header and add that class to any element on the page.
Position
- Sticky: the header stays at the top of the screen as the page scrolls.
- Sticky, over the first section: the header floats above the page, so a hero can sit behind it. It is see-through at the top unless you say otherwise.
- Not sticky: only the scrolled look and the other effects.
- Only from this screen width up: below it the header is an ordinary header with none of these effects.
- A top header sits below the WordPress admin bar when it is showing. Links to
#anchorsland below the header, not behind it.
When the scrolled look starts
- After scrolling past the header’s own height.
- After a distance you choose, in pixels.
- When the first section under the header has scrolled past.
Hide and show
The header can slide up out of view or fade out as the visitor scrolls down, and returns as soon as they scroll up. Small movements are ignored (you set how small). It never hides near the top of the page, while the keyboard focus is inside it, or while a mobile menu is open.
Top and scrolled looks
- Background and text colour at the top of the page, and again once scrolled, so you can go from a see-through header with white text to a white header with dark text.
- A blur behind the header once scrolled (works best with a see-through background such as
rgba(255,255,255,.8)). - Add a soft shadow or a thin line once scrolled.
- Buttons keep their own colours.
Shrink
- Top and bottom padding once scrolled, for the sections inside the header.
- Logo height once scrolled. The logo keeps its proportions. The logo is found with
.brxe-logo img; change the selector if yours is different.
Changing individual elements
Add these classes to elements inside the header:
ah-hide-scrolled: disappears once scrolled, such as a tagline or a phone number.ah-fade-scrolled: fades out once scrolled but keeps its space.ah-show-scrolled: only appears once scrolled, such as a Book now button.
Accessibility
- The header stays visible while focus is inside it, and reappears if the keyboard moves into it while it is hidden.
- Reduced-motion settings make every change instant.
Good to know
- The element controls the Bricks header (
#brx-header) unless you give it another selector in Header to control. That is how the demo page works: it builds its own header inside the page. - Only one selector is used. If you have two different headers, add one Header Scroll element per template.
- It does not change the header’s layout; style the header itself in Bricks as usual.