Q:

sticky header

.navigation {
   /* fixed keyword is fine too */
   position: sticky;
   top: 0;
   z-index: 100;
   /* z-index works pretty much like a layer:
   the higher the z-index value, the greater
   it will allow the navigation tag to stay on top
   of other tags */
}
4

/* The navigation bar */
.navbar {
  overflow: hidden;
  
  background-color: #333;
  position: fixed; /* Set 
  the navbar to fixed position */
  top: 0; 
/* Position the navbar at the top of the page */
  width: 
100%; /* Full width */
}

/* Links inside the navbar */

  .navbar a {
  float: left;
  display: 
  block;
  color: #f2f2f2;
  text-align: 
  center;
  padding: 14px 16px;
  
  text-decoration: none;
}

/* Change background on mouse-over */
.navbar 
  a:hover {
  background: #ddd;
  color: 
  black;
}

/* Main 
content */
.main {
  margin-top: 30px; /* Add a top 
  margin to avoid content overlay */
} 
0

  // When the user scrolls the page, execute myFunction 
window.onscroll = 
  function() {myFunction()};

// Get the header
var header = document.getElementById("myHeader");

  
// 
  Get the offset position of the navbar
var sticky = 
  header.offsetTop;

// Add the sticky class to the header when you reach 
  its scroll position. Remove "sticky" when you leave the scroll position
function myFunction() {
  if (window.pageYOffset 
  > sticky) {
    header.classList.add("sticky");
  } 
  else {
    header.classList.remove("sticky");
  }

  } 
0
#header {
  position: fixed;
}

#content {
  margin-top: 100px;
}
-1

New to Communities?

Join the community