Jump to content

Sticky Dropdown Navbar Problem


RackonTheRocket

Recommended Posts

I have the Problem that my Dropdown Menu is not working anymore after I made the navigation bar sticky

 

HTML:

<div class="navbar">
    <a  href="#homeNav" id="home">Home</a>
    <a href="#contact">Kontakt</a>
    <a href="#ueberuns">Über Uns</a>
    <a href="#unserteam">Unser Team</a>
  <div class="dropdown">
    <button class="dropbtn" onclick="leistungen()">Leistungen <i class="fa fa-caret-down"></i> </button>
    <div class="dropdown-content" id="myDropdown"> <a href="leistungen.html#fassaden">Fassadenanstrich</a> <a href="leistungen.html#innenGestaltung">Innengestaltung</a>  <a href="leistungen.html#wärmeSchutz">Vollwärmeschutz</a><a href="leistungen.html#spachtelArbeit">Spachtelarbeiten</a><a href="leistungen.html#weiteres">Weiteres</a> </div>
  </div>
</div>

 

CSS:

/* CSS Document */


.navbar {
  overflow: hidden;
  background-color: #a52121;
  font-family: Arial, Helvetica, sans-serif;
  position: sticky;
  position: -webkit-sticky;
  top: 0;
}

.navbar a {
  float: right;
  font-size: 1.1vw;
  color: white;
  text-align: center;
  padding: 1vw 1.2vw;
  text-decoration: none;
    
}

.dropdown {
  float: right;
  overflow: hidden;
    
}

.dropdown .dropbtn {
  cursor: pointer;
  font-size: 1.1vw;  
  border: none;
  outline: none;
  color: white;
  padding: 1vw 1.2vw;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
    
}

.navbar a:hover, .dropdown:hover .dropbtn, .dropbtn:focus {
  background-color: red;
}

.dropdown-content {
  display: none;
    margin-left: -1.75vw;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0vw 0.3vw 1.6vw 0vw rgba(0,0,0,0.2);
  z-index: 1;
 

}

.dropdown-content a {
  float: none;
  color: black;
  padding: 1vw 1.2vw;
  text-decoration: none;
  display: block;
  text-align: left;
    
}

.dropdown-content a:hover {
  background-color: #ddd;
}

.show {
  display: block;
}
#home{
    background-color: #696969;
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...