Divi  – A section above the main header

Divi – A section above the main header

This is a cool way to add a whole section (or layout if you wish) above the main navigation and then have it stick to the top during scroll. It’s pretty cool.


This is what it looks like:

View post on imgur.com


You need this

To start with, go get the child theme,

or if you’re using a child theme, add this code to your functions.php

And make sure your header is set to stick to the top.


The video


The code

Here’s the php code you need to add right above header id=”main-header” in the header.php file. (copy the header.php from Divi into the child theme if it’s not already there. Edits to the child theme file won’t be lost on updates to the parent theme)

<?php if ( is_home() || is_front_page() ) : 
	echo do_shortcode('[ai_layout_sc id="000000"]');
 endif; ?>

Please change the shortcode id number to whatever number your section had in the library.

Then add this CSS

.home.page #page-container {
 padding-top:0px !important
.home.page #page-container header#main-header {
 -webkit-transition:all 0.5s ease-in-out;
 -moz-transition:all 0.5s ease-in-out;
 -o-transition:all 0.5s ease-in-out;
 -ms-transition:all 0.5s ease-in-out;
 transition:all 0.5s ease-in-out
.home.page #page-container header#main-header.et-fixed-header {
 -webkit-transition:all 0.5s ease-in-out;
 -moz-transition:all 0.5s ease-in-out;
 -o-transition:all 0.5s ease-in-out;
 -ms-transition:all 0.5s ease-in-out;
 transition:all 0.5s ease-in-out

[sc name=”customcss”]


and you’re done!


[sc name=”learn css”]



Photo by Li Yang on Unsplash

Why no ads?

Hi, my name is PK, and welcome to my website, almost inevitable design. I maintain and publish on this site for two reasons.

  1. To give back to the community. I learned so much from people's tutorials and StackOverflow that I wanted to contribute and help others.
  2. To provide a more structured learning experience. People struggle to find the course that guides them from start to finish, based off of real life experience, and my courses provide that.

The only "ads" I have here are for my own courses, and maybe an affiliate link, but that's it. They fund the website resources and provide more motivation for me to product better content.

Any bit of interest helps. Even sharing with your feidns, suggesting my courses to your developer or designer, or subscribing to my YT channel, or joining our Discord. Thanks and I'll see you around!

The Web Design Space

TWDS is my web design agency. If you're looking for premium quality, reliable, web design and development, come see what we're about!
Learn More
Choose "Paythen" at checkout for an interest free 10 week payment plan.
Leave a Reply

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

  1. Nice work! Could you use cooie or session or something to display this only when user first time visit homepage?

    • Hi, unfortunately, I’m not good with setting cookies, sorry. You might have to use popups for this.

New tutorials