Jump to content

Fixed Parity Deal Banner Below Fixed Navigation

Recommended Posts

Here's my website: https://uxplaybook.org/

How do I fixed the Parity Deals banner below my navigation? 

Right now its on Top and hides as I scroll.

Need some help fixing this under my navigation.

Here's the code I used:

<!-- Start of Parity Deals Banner -->
<script>
function debounceCustom(func, timeout =300) 
{
let timer=null;
  return (...args) => {clearTimeout(timer);
    timer = setTimeout(() => { func.apply(this, args); }, timeout);
  };
}
function fixHeader() {
  window.scrollY;
  const findBanner = document.getElementsByClassName('parity-banner-has-logo');
  const findMenu = document.getElementsByClassName('header-announcement-bar-wrapper');
  if (findBanner.length > 0 && findMenu.length > 0) {
    const banner = findBanner[0];
    const menu = findMenu[0];
    banner.style.zIndex = 100;
    if (window.scrollY === 0) {
      menu.style.marginTop = banner.offsetHeight.toString() + 'px';
    } else {
      menu.style.marginTop = '0px';
    }
  }
}
document.addEventListener('scroll', debounceCustom(fixHeader), { passive: true });
fixHeader();
</script>
<!-- End of Parity Deals Banner -->
Link to comment
  • Replies 0
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.