I want my navigation bar to be sticky, but it's not working. I'm also using some basic jQuery to toggle slidedown for class "dropmenu". I also tried position sticky for <a>
element and still it wouldn't work.
This is HTML and CSS :
.dropmenu {
display: block;
height: 65px;
width: 100%;
background: url("images/menuicon.png") no-repeat 98% center;
background-color: #404040;
cursor: pointer;
}
nav ul {
padding: 0;
overflow: hidden;
background: #505050;
display: none;
}
nav ul li {
display: block;
float: none;
text-align: left;
width: 100%;
margin: 0;
}
nav ul li a {
color: white;
padding: 10px;
border-bottom: 1px solid #404040;
display: block;
margin: 0;
}
div.sticky {
position: sticky;
top: 0;
}
<div class="center">
<header>
<img class="headerImage" src="images/header.png"/>
<hr class="menu">
<div class="sticky">
<a class="dropmenu"></a>
<nav class="desktop">
<ul>
<li><a href="index.php">Sertet</a></li>
<li><a href="index.php">Rtretrti</a></li>
<li><a href="photos.php">ertettterli</a></li>
<li><a href="index.php">retemi</a></li>
<li><a href="index.php">Kerterti</a></li>
</ul>
</nav>
</div>
</header>
<hr class="menu">
<p>content goes here</p>
</div>
So what would be the problem?