Hiding siteheader and shyheader casues flickering when scrolling

New Contributor


I know that it is not best practice from Microsoft to hide the header but this is just for our local intranet where we are trying to build a custom mega menu with an application customizer.


What we are doing is in the oninit of the webpart we are hiding the siteheader and shyheader wich is working fine. But the sideeffects are that the page is kind of "jumpy/flickering" when we scroll to bottom and top.


the code for hiding the elements is:

    const cssShyHeader = '[data-automationid="ShyHeader"]{display:none !important}';
    const cssSiteHeader = '[data-automationid="SiteHeader"]{display:none !important}';
    const cssHubNav = '.ms-HubNav{display:none !important}';
    const head = document.getElementsByTagName("head")[0] || document.documentElement;
    let customStyle = document.createElement("style");
    customStyle.title = "customcss";
    customStyle.type = "text/css";


Is there some default css animation we can get rid of?



1 Reply
Hi, you can hide the ShyHeader with that code and there is no flickering.
Just Replace the header id matching your´s.
div .shyHeader-71{
display:none !important;