Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@illustrateer illustrateer commented Oct 8, 2016

can't make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.