Subnav/dropdown menu inside a Navigation Bar

Wednesday, February 11, 2026

CODE : Responsive Navbar with Dropdown_for Bald Eagle Website.#1_(updated 07-20-2021)

<!doctype html>





<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />

<style>

body {margin:0;font-family:Arial}


.topnav {

  overflow: hidden;

  background-color: #333;

}


.topnav a {

  float: left;

  display: block;

  color: #f2f2f2;

  text-align: center;

  padding: 14px 16px;

  text-decoration: none;

  font-size: 17px;

}


.active {

  background-color: #4CAF50;

  color: white;

}


.topnav .icon {

  display: none;

}


.dropdown {

  float: left;

  overflow: hidden;

}


.dropdown .dropbtn {

  font-size: 17px;    

  border: none;

  outline: none;

  color: white;

  padding: 14px 16px;

  background-color: inherit;

  font-family: inherit;

  margin: 0;

}


.dropdown-content {

  display: none;

  position: absolute;

  background-color: #f9f9f9;

  min-width: 160px;

  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);

  z-index: 1;

}


.dropdown-content a {

  float: none;

  color: black;

  padding: 12px 16px;

  text-decoration: none;

  display: block;

  text-align: left;

}


.topnav a:hover, .dropdown:hover .dropbtn {

  background-color: #555;

  color: white;

}


.dropdown-content a:hover {

  background-color: #ddd;

  color: black;

}


.dropdown:hover .dropdown-content {

  display: block;

}


@media screen and (max-width: 600px) {

  .topnav a:not(:first-child), .dropdown .dropbtn {

    display: none;

  }

  .topnav a.icon {

    float: right;

    display: block;

  }

}


@media screen and (max-width: 600px) {

  .topnav.responsive {position: relative;}

  .topnav.responsive .icon {

    position: absolute;

    right: 0;

    top: 0;

  }

  .topnav.responsive a {

    float: none;

    display: block;

    text-align: left;

  }

  .topnav.responsive .dropdown {float: none;}

  .topnav.responsive .dropdown-content {position: relative;}

  .topnav.responsive .dropdown .dropbtn {

    display: block;

    width: 100%;

    text-align: left;

  }

}

</style>




<div class="topnav" id="myTopnav">

  <a href="https://tuyendinh75.blogspot.com/"#home" class="active">Home</a>

 <div class="dropdown">

    <button class="dropbtn">Travel 

    <div class="dropdown-content">

      <a href="https://tuyendinh75.blogspot.com/2021/02/travel.html"#">Travel</a>

     </div>

    </button></div> 

  <div class="dropdown">

    <button class="dropbtn">Discover

      <i class="fa fa-caret-down"></i>

    </button>

    <div class="dropdown-content">

      <a href="https://tuyendinh75.blogspot.com/2021/02/america.html"#">America</a>

      <a href="https://tuyendinh75.blogspot.com/2021/02/vietnam.html"#">Vietnam</a>

      <a href="https://tuyendinh75.blogspot.com/2021/02/travel.html"#">Travel</a>

    </div> 

</div>

<div class="dropdown">

    <button class="dropbtn">Categories 

      <i class="fa fa-caret-down"></i>

    </button>

    <div class="dropdown-content">

      <a href="https://tuyendinh75.blogspot.com/2021/02/history.html">History</a>

      <a href="https://tuyendinh75.blogspot.com/2021/02/art.html">Art </a>

      <a href="https://tuyendinh75.blogspot.com/2021/02/literature.html">Literature </a> 

      <a href="https://tuyendinh75.blogspot.com/2021/02/music.html">Music </a>

      <a href="https://tuyendinh75.blogspot.com/2021/02/entertainment.html">Entertainment</a>

<a href="https://tuyendinh75.blogspot.com/2021/02/travel.html"">Travel</a>

    </div>

  </div> 

<div class="dropdown">

    <button class="dropbtn">Collections 

      <i class="fa fa-caret-down"></i>

    </button>

    <div class="dropdown-content">

      <a href="https://tuyendinh75.blogspot.com/2021/02/photo.html">Photo</a>

      <a href="https://tuyendinh75.blogspot.com/2021/02/video.html">Video</a>

     <a href="https://tuyendinh75.blogspot.com/2021/02/collections.htm">Documents</a> 

</div>

  </div> 

<div class="dropdown">

    <button class="dropbtn">Video 

      <i class="fa fa-caret-down"></i>

    </button>

    <div class="dropdown-content">

      <a href="https://tuyendinh75.blogspot.com/2021/02/video.html">Video</a>

 </div>

  </div> 

<div class="dropdown">

    <button class="dropbtn">Documents 

      <i class="fa fa-caret-down"></i>

    </button>

    <div class="dropdown-content">

      <a href="https://tuyendinh75.blogspot.com/2021/02/collections.html">Documents</a>

 </div>

  </div> 

<div class="dropdown">

    <button class="dropbtn">Explore 

      <i class="fa fa-caret-down"></i>

    </button>

    <div class="dropdown-content">

      <a href="https://tuyendinh75.blogspot.com/2021/02/explore.html">Explore</a>

      <a href="https://tuyendinh75.blogspot.com/2021/02/more.html">More</a>

</div>

</div> 

<div class="dropdown">

<button class="dropbtn">Links 

<i class="fa fa-caret-down"></i>

</button>

<div class="dropdown-content">

<a href="https://tuyendinh75.blogspot.com/2021/02/links.html">Links</a>

</div>

  </div><a href="https://www.blogger.com/profile/00687270253130234513">About</a> 



<div style="padding-left:16px">

  <h2>Responsive Topnav with Dropdown</h2>

  

</div>


<script>

function myFunction() {

  var x = document.getElementById("myTopnav");

  if (x.className === "topnav") {

    x.className += " responsive";

  } else {

    x.className = "topnav";

  }

}

</script>



</div></!doctype>

No comments:

Post a Comment