Dropdown Menu SourceCode

HTML Code

          
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="styles.css" />
    <title>Dropdown Menu </title>
  </head>
  <body>
    
    <div class="dropdown">
      <button class="dropbtn">Menu 1</button>
      <div class="dropdown-content">
        <div class="content-section">About Us</div>
        <div class="content-section">Our Team</div>
        <div class="content-section">Contact</div>
      </div>
    </div>
     
     <div class="dropdown">
     <button class="dropbtn">Menu 2</button>
     <div class="dropdown-content">
       <div class="content-section">Services</div>
       <div class="content-section">Portfolio</div>
       <div class="content-section">Testimonials</div>
     </div>
   </div>
    
    <div class="dropdown">
      <button class="dropbtn">Menu 3</button>
      <div class="dropdown-content">
        <div class="content-section">Blog</div>
        <div class="content-section">FAQ</div>
        <div class="content-section">Support</div>
      </div>
    </div>
  </body>
</html>
          
        

CSS Code

          
            /* General Reset */
            * {
              margin: 0;
              padding: 0;
              box-sizing: border-box;
            }
            
            /* Dropdown Menu Container */
            .dropdown {
              position: relative;
              display: inline-block;
              margin: 20px;
            }
            
            /* Style the dropdown button */
            .dropbtn {
              background-color: #007bff;
              color: white;
              padding: 10px 20px;
              border: none;
              cursor: pointer;
              border-radius: 4px;
              font-size: 16px;
              transition: background-color 0.3s ease;
            }
            
            .dropbtn:hover {
              background-color: #0056b3;
            }
            
            /* Dropdown Content */
            .dropdown-content {
              display: none;
              position: absolute;
              background-color: #f9f9f9;
              min-width: 150px;
              box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
              z-index: 1;
              padding: 10px 0;
              border-radius: 4px;
              overflow: hidden;
            }
            
            /* Style the content inside dropdown */
            .content-section {
              padding: 10px 15px;
              margin: 2px 0;
              font-size: 14px;
              color: #555;
              border-bottom: 1px solid #ddd;
              transition: background-color 0.3s ease;
              cursor: pointer; /* Change cursor to pointer to make them clickable */
            }
            
            .content-section:hover {
              background-color: #007bff;
              color: white; /* Change text color on hover */
            }
            
            /* Hover effect to show content on menu hover */
            .dropdown:hover .dropdown-content {
              display: block;
            }