Skip to content

Instantly share code, notes, and snippets.

@johnnyopao
Last active December 15, 2022 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save johnnyopao/445088ba176c04b0a5ba to your computer and use it in GitHub Desktop.
Save johnnyopao/445088ba176c04b0a5ba to your computer and use it in GitHub Desktop.
Hidden from top Fixed Header Menu
<script>
//Hidden Fixed header v1.1
//Replace ID below with your box ID
var boxToFix = '#lp-pom-box-88';
//Set the number of pixels to scroll before showing the header
var scrollPositionToShowHeader = 50;
var boxParent = $(boxToFix).parent();
var boxClone = $(boxToFix).clone();
$(boxClone).appendTo(boxParent).css({"position":"fixed", "left":"0", "top":"0", "width":"100%", "z-index":"899"}).children().remove();
$(boxToFix).css({"position":"fixed", "left":"auto", "top":"0px", "width":"100%", "z-index":"999", "border-style":"none none none none", "border-width":"0px", "background":"none"});
showOrHideHeader();
function showOrHideHeader() {
var currentPositionFromTop = $(window).scrollTop();
if (currentPositionFromTop > scrollPositionToShowHeader) {
$(boxToFix).show();
$(boxClone).show();
} else {
$(boxToFix).hide();
$(boxClone).hide();
}
}
$(window).scroll(function() {
showOrHideHeader();
});
</script>
@illustrateer
Copy link

can't make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment