I want to create a website with a menu bar that stays at the top even on long pages. However, when I use position: sticky in CSS, the menu disappears after scrolling a certain distance. Does anyone know how to fix this issue?
HTML:
<nav>
<ul class="menu-area">
<li><a href="./index.html">Home</a></li>
<li><a href="./Acclaims.html">Acclaims</a></li>
<li><a href="https://www.youtube.com/user/asdf" target="_blank">Youtube</a></li>
<li>
<a href="https://www.google.com/search?asdf"
target="_blank">Images</a></li>
<li><a href="./contact.html">Contact</a></li>
</ul>
CSS:
.menu-area li a {
text-decoration: none;
color: #000;
letter-spacing: 4px;
text-transform: uppercase;
display: block;
padding: 0 25px;
font-size: 14px;
line-height: 30px;
z-index: 1;
}
.menu-area li {
list-style: none;
display: inline-block;
}
nav {
padding: 10px 20px 10px 10px;
text-align: center;
background: #eaedf2;
margin: auto;
width: calc(100%);
position: sticky;
top: 0;
}
.menu-area li a:hover {
background: black;
color: #eaedf2;
}