top of page
Sticky Header

Sticky Header

Keep the site header visible when a visitor scrolls the page.

Intermediate.png

Beginner

19K

Published:

January 1, 2020

Girl Enjoying her Drink

by

Anchor 1
Hire a Developer

Example Description

In this example site header is kept visible when a visitor scrolls the page.

Example Code

Tab 1

.

Tab 2

.

Tab 3

.

This code solution can be complicated.

How We Built It

This example demonstrates how to use events to freeze your header and change its appearance as users scroll through your site.

 

To create a sticky header, we will use two Classic Strip elements—one with a transparent background and the other with a white background. Customize the transparent Strip, adding header elements like your name, logo and a Menu. Once this Strip is designed, duplicate it and change its background color to white. Drag and drop each Strip and Attach to Header.


First, we made the white header hidden on load and added an anchor, which we'll use as a trigger point for the switch and add to it two event handlers—onViewportLeave and onViewportEnter—to change the header background as users scroll through the site.

 

You can put this either in your page code to make the change in one place, or in the site code to make it in all pages.


Next Steps


  1. Open this example in the Editor to work with the template.

  2. Publish the site.

  3. Learn how to work with examples in Velo.

APIs We Used

Non-code example.

Non-code example.

Related Articles

Article Link

Hire a Developer

Velo solutions are powerful tools, but building them on your own can be challenging. Let an experienced Velo development shop build it for you, so you can keep working on your site or business.

Related Examples

Did this help?

Yes

|

No

Thanks for your feedback!

Hide & Show Elements

Hide & Show Elements

Hide and show elements in response to user interactions.

Intermediate.png

Intermediate

Hide and Show an Image

Hide and Show an Image

Show and hide an image according to the clicked button.

Intermediate.png

Beginner

Collapse Elements

Collapse Elements

Collapse and expand groups of elements.

Intermediate.png

Beginner

Change Site Content

Change Site Content

Change site content in response to a user interaction.

Intermediate.png

Beginner

Anchor 2
bottom of page