Resolving Sticky State Issues with Multiple Sticky Headers in Divi

Written by Dan Mossop

When working with the Divi Theme Builder, it's quite common to create a custom header with multiple sections. You might want both sections to be sticky, but you may hit a snag with this setup: the first one starts off correctly as non-sticky, while the second one appears in the sticky state right away. This creates inconsistent styling as the sticky styles apply only to the second section instead of both upon initial load.

Here's an example of a two section header which is styled grey in its non-sticky state (this is how we'd want the header to display on page load). In its sticky state the sections are colored green and blue, which is how it displays after scrolling. Finally, we have the incorrect initial state which is what actually gets displayed on first page load – the top section is non-sticky and the bottom is in its blue sticky state:

Non-sticky State

Sticky State

Initial State (Incorrect)

Why does this happen in Divi?

Divi seems to treat the first section differently from other sticky sections. It allows the first section in your header to begin as non-sticky, which is great for single-section sticky header situations. This setup lets the header start in its regular state and become sticky as you scroll down. 

But, here's the problem: Divi also seems to anticipate other sticky situations, like social media bars that need to appear sticky immediately when the page loads in a scrolled state. Consequently, Divi tends to treat sections beyond the first as sticky content, which should be sticky 'right out of the gate' so to speak. This assumption means your second header section shows up as sticky immediately, since it's already in the position in the page at which it becomes sticky.

Hence you end up with the first section in a non-sticky state and the second section in a sticky state.

Fixing the Multi-Section Sticky Header

Don't worry; there's a couple of straightforward fixes to get your header sections behaving nicely.

Merge Sticky Sections

The first solution is to merge your header elements into one section. This ensures they share the same sticky behavior, starting as non-sticky and becoming sticky together as you scroll.

Adjust Sticky Settings

Another method is to tweak the settings of your second sticky section. By changing:

Section Settings > Advanced > Scroll Effects > Sticky Top Offset = -1px

…you essentially tell Divi, 'Don't go sticky until at least one pixel of scroll has occurred.' The result? The section begins as non-sticky and transitions to sticky just after a slight scroll – exactly what we want.

Conclusion

Handling multiple sticky sections in Divi Theme Builder can be a bit fiddly, but with a little know-how, you can ensure your header sections only become sticky when you intend them to. Whether you combine your header elements into a single section or adjust the Sticky Top Offset for the second section, you're now equipped to solve this sticky situation with ease. 

Enhance Engagement Effortlessly with WP Magic CTAs

Transform your WordPress posts into conversion powerhouses with WP Magic CTAs. This AI-driven plugin tailors call-to-actions for each post, boosting engagement and conversions seamlessly. Perfect for sticky content and beyond.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

0 Comments

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.

Latest From Divi Booster

Enable Automatic Looping for YouTube Videos in the Divi Video Module

Enabling automatic looping for YouTube videos in your Divi video module ensures that content plays seamlessly and continuously without interruption. This feature can enhance user engagement, highlight key information, or create dynamic visual effects on your website....

Hide Video Controls in Divi Video Module

Disabling YouTube video controls in the Divi Video Module helps create a seamless, distraction-free viewing experience for your site visitors. This approach is useful when you want full control over how your video content appears and is interacted with on the page, or...

Mute YouTube Videos by Default in the Divi Video Module

In the Divi Video Module, starting your YouTube videos muted by default can create a more user-friendly browsing experience on your webpage. It is particularly beneficial for reducing distractions, enhancing visitor engagement, and providing a seamless content preview...

Autoplay Videos in Divi Video Module

Enabling videos in your Divi video module to start playing automatically can enhance both the site's design and user engagement. To ensure full compatibility with browser requirements, such as Chrome's autoplay policy, it's often necessary to start your videos muted...

How to Add the Post Status in Divi's Dynamic Content

Divi's Dynamic Content feature is great for enhancing your post/page templates with post-specific information. While Divi includes an option to show information such as the Post Created Date using Dynamic Content, there is no equivalent option for the Post Status....

Random Divi Posts