Skip to content

Instantly share code, notes, and snippets.

@GustavoNapa
Last active December 22, 2023 17:21
Show Gist options
  • Save GustavoNapa/6ebf053d5aa0a98979d4a02b799d2e6e to your computer and use it in GitHub Desktop.
Save GustavoNapa/6ebf053d5aa0a98979d4a02b799d2e6e to your computer and use it in GitHub Desktop.
Fixar menu em site Wordpress
#site-header.navbar-fixed-top{
display: block;
}
.navbar-fixed-top{
position: fixed!important;
z-index: 998;
background: #FFF;
top: 0;
left: 0;
width: 100%;
animation-name: fadeInOpacity;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-duration: 0.5s;
}
.navbar-fixed-top #site-logo-inner a img{
height: 100px
}
.margin-main-fixed{
margin-top: 255px;
}
const menu = document.getElementById("site-header");
const mainContent = document.getElementById("main");
document.addEventListener("scroll", function(event) {
var scroll = window.scrollY
if (scroll > 300) {
menu.classList.add("navbar-fixed-top");
mainContent.classList.add("margin-main-fixed");
} else {
menu.classList.remove("navbar-fixed-top");
mainContent.classList.remove("margin-main-fixed");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment