Incorporating a Dropdown Feature into the Side Navigation Panel

Help needed with activating dropdown menu on hover.

body { 
    
    font-family: 'Alegreya Sans', sans-serif; 
    overflow-x: hidden; 
    background: gray; 
    color: white; 
} 
#content { 
    padding: 15px; 
    transition: margin-left 0.7s; 
    overflow: hidden; 
    width: 100%; 
} 
.slide a { 
    color: #000; 
    font-size: 36px; 
} 
.nav .close { 
    position: absolute; 
    top: 8px; 
    right: 22px; 
    margin-left: 50px; 
    font-size: 30px; 
    color: #ccc; 
} 
.nav { 
    height: 100%; 
    width: 0; 
    position: fixed; 
    z-index: 1; 
    top: 0; 
    left: 0; 
    background-color: #282828; 
    overflow-x: hidden; 
    padding-top: 60px; 
    transition: 0.7s; 
} 

...
 
<!DOCTYPE html> 
<html> 
<head> 
  <title>Home</title> 
  <script src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script> 
  <link rel="stylesheet" href="style.css"> 
<script> 
  function openSlideMenu(){ 
    document.getElementById('menu').style.width = '250px'; 
    document.getElementById('content').style.marginLeft = '250px'; 
  } 
  function closeSlideMenu(){ 
    document.getElementById('menu').style.width = '0'; 
    document.getElementById('content').style.marginLeft = '0'; 
  } 
</script> 
</head> 
<body>

...

Having trouble making the dropdown feature active by hovering over "Dashboards".

View full HTML code here

Access CSS snippets here

Any assistance in making the dropdown work would be appreciated. Thank you!

Answer №1

Here is the solution I came up with:

function openSlideMenu(){ 
    document.getElementById('menu').style.width = '250px'; 
    document.getElementById('content').style.marginLeft = '250px'; 
} 
function closeSlideMenu(){ 
    document.getElementById('menu').style.width = '0'; 
    document.getElementById('content').style.marginLeft = '0'; 
} 
body {     
    font-family: 'Alegreya Sans', sans-serif; 
    overflow-x: hidden; 
    background: gray; 
    color: white; 
} 

#content { 
    padding: 15px; 
    transition: margin-left 0.7s; 
    overflow: hidden; 
    width: 100%; 
} 

.slide a { 
    color: #000; 
    font-size: 36px; 
} 

.nav .close { 
    position: absolute; 
    top: 8px; 
    right: 22px; 
    margin-left: 50px; 
    font-size: 30px; 
    color: #ccc; 
} 

.nav { 
    height: 100%; 
    width: 0; 
    position: fixed; 
    z-index: 1; 
    top: 0; 
    left: 0; 
    background-color: #282828; 
    overflow-x: hidden; 
    padding-top: 60px; 
    transition: 0.7s; 
} 

.nav a.item { 
    display: flex; 
    flex-direction: row; 
    padding: 18px 30px; 
    font-size: 30px; 
    text-decoration: none; 
    color: #ccc; 
    background-color: #3d3d3d; 
    border-top: 1px solid #ccc; 
} 

.nav .last { 
    border-bottom: 1px solid #ccc; 
} 

.nav a.item:hover { 
    color: #fff; 
    background-color: #cf0000; 
    transition: 0.4s; 
} 

.nav .icon { 
    padding-right: 10px; 
    font-size: 35px; 
} 

.nav ul { 
    display: flex; 
    position: absolute; 
    width: 100%; 
    margin-top: 50px; 
} 

.nav ul li { 
    list-style: none; 
} 
.nav ul li a.inline { 
    font-size: 26px; 
    color: #ccc; 
    padding: 6px 5px 3px; 
} 

.nav ul li a.inline:hover { 
    color: #cf0000; 
} 

.content p{ 
  font-size: 18px; 
  text-align: center; 
  margin-left: 310px; 
} 

.footer-home{ 
    position: fixed; 
    left: 0; 
    bottom: 0; 
    width:100%; 
    height: auto; 
    background-color:#282828; 
    color: white; 
    padding: 10px; 
    text-align: center; 
} 


* { 
    box-sizing: border-box; 
  } 

.column { 
    float: left; 
    width: 33.33%; 
    padding: 5px; 
  } 

/* Clearfix (clear floats) */ 
.row::after { 
    content: ""; 
    clear: both; 
    display: table; 
  }

.dropbtn {
    display: flex; 
    flex-direction: row; 
    padding: 18px 30px; 
    font-size: 30px; 
    text-decoration: none; 
    color: #ccc; 
    background-color: #3d3d3d; 
    border-top: 1px solid #ccc; 
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  width: 100%;
}

.dropdown-content a {
    display: flex; 
    width: 100%;
    flex-direction: row; 
    padding: 18px 30px; 
    font-size: 30px; 
    text-decoration: none; 
    color: #ccc; 
    background-color: #3d3d3d; 
    border-top: 1px solid #ccc;
}

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

.dropdown:hover .dropdown-content {display: block;}

.dropdown:hover .dropbtn {background-color: #cf0000;}
<script src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script> 

<div id="content"> 

  <span class="slide"> 
      <a href="#" onclick="openSlideMenu()"> 
        <i class="fas fa-bars"></i> 
      </a> 
  </span> 

  <div id="menu" class="nav"> 

      <a href="#" class="close" onclick="closeSlideMenu()"> 
        <i class="fas fa-times"></i> 
      </a> 

      <img src="#" alt="" width="150" height="100"> 
      <a href="index.html" class="item"><i class="fas fa-home icon"></i>Home</a> 

      <div class="dropdown">

        <a class="dropbtn">
          <i class="fas fa-desktop icon"></i>
          Dashboards
        </a>

        <div class="dropdown-content">
          <a href="#">Link 1</a>
          <a href="#">Link 2</a>
          <a href="#">Link 3</a>
        </div>

      </div>

      <a href="maps.html" class="item">
        <i class="fas fa-map-marker icon"></i>
        Engagements
      </a> 
      
      <a href="contact.html" class="item last">
        <i class="fab fa-wpforms icon"></i>
        Contact
      </a> 

  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Adding Information to a Material Design Card

Currently, I am delving into frontend development and honing my CSS skills. In my latest project, I have incorporated a mat card which can be viewed in the linked image https://i.sstatic.net/TEDcg.png. Below is an excerpt of my code: <div class=&quo ...

The issue of not being able to type in the sweetalert 2 input within a material UI modal in a

Within a card displaying an order, there is a sweetalert2 popup that opens when trying to cancel the order, asking for a cancellation reason. This feature works seamlessly on the orders screen. https://i.sstatic.net/RWhOA.png <Grid item md={8} sm={12}&g ...

Solution for displaying as a table cell in Internet Explorer 6 and 7: Workaround

I am currently working on creating a single-row CSS table with multiple cells, aiming to vertically center text within each cell. The desired table layout is as follows: <table width="100%" height="54" border="0" bgcolor="red"> <tr> <t ...

Expand the dimensions of the shinydashboard dashboard page

Currently, I am using shinydashboard and have formatted my ui code in the following way: ui = dashboardPage(skin="black", dashboardHeader(disable = T), dashboardSidebar(width=300), dashboardBody() ...

Reveal and conceal information with a customized web address

I have a PHP and MySQL blog that I want to display in a div using show and hide JavaScript functions. Everything works fine with other divs, but the issue arises when clicking on a vanity URL causing my webpage to refresh every time it's clicked. The ...

Is it possible for the browser to ignore the style.min.css file and only use the style.css file when both files are linked in the HTML?

I have a question about file downloads: If I have two files named Style.css and Style.min.css in the same directory, and my HTML page references Style.css, will the browser or server ever download the Style.min.css file instead? (Even if they have the sa ...

The Angular template driven forms are flagging as invalid despite the regExp being a match

My input looks like this: <div class="form-group"> <label for="power">Hero Power</label> <input [(ngModel)]="model.powerNumber" name="powerNumber" type="text" class="form-control" pattern="^[0-9]+$"id= ...

Resize images to perfectly fit dimensions of your choice

After conducting thorough research and experimenting with various jQuery and Javascript solutions, I was unable to find a way to dynamically scale images both horizontally and vertically to a specific size while maintaining their aspect ratio. In my parti ...

Create a dynamic dropbox using JavaScript/JQuery in an HTML page

I am currently working on implementing 3 different drop down boxes that are triggered by 4 different buttons. These drop down boxes should appear within the #apple div. When Button B1 is clicked, the drop down options include Apple, Mango, and Papaya. Whe ...

How can Bootstrap 4 be utilized to achieve a responsive height on a single page application with no scrolling?

Embarking on the journey of responsive website design as a beginner in front end development, I am currently working on creating a basic angular chat application with bootstrap. Keeping responsiveness in mind throughout the design process is my goal, but I ...

Is it possible to initially design a login page using HTML/CSS and JavaScript, and then integrate VUE into it?

As part of a school project, I am tasked with developing a web-based application for a library system. The goal is to create a platform where librarians can login and manage books by adding, removing, or editing them. My responsibility lies in handling the ...

Showcasing a set of divs - arranged in rows of three

Utilizing bootstrap 3 to exhibit user contact details on a website has proven to be challenging. My initial idea was to use the col-md-4 bootstrap CSS class to showcase three contact details per line, but it seems my expectation did not match reality. Th ...

The @html.TextBoxFor model value does not appear pre-filled or set for the date type

I am using the @html.TextBoxFor method with a specified type of date. However, when rendering the view, the model value (retrieved from the database) is not being set. Here is an example of my code: <tr> <td>@Html.Label("ReferenceId")< ...

Failing to verify the presence of specific text within a dropdown menu using Selenium

Previously, I successfully implemented this code, however, the HTML/CSS for the dropdown has since changed and now I am unable to get it to function correctly. Below is the structure for the dropdown code, with specific text highlighted that I am trying t ...

Convert HTML to PDF on iOS with our reliable library

Looking for recommendations on an iOS library that can easily convert HTML to PDF. Specifically looking for something with simple functionality. ...

retrieving the value of an AngularJS variable based on which radio button

I've experimented with various versions of code, but I haven't been able to find a solution yet. Here's the code snippet: <div class="well"> <h3>{{policies.aul.name}}</h3> <ul style="list-style: none;"> ...

The back div is not retained on the second animation when flipping the card

In my card with a unique animation, clicking on the "Edit" button triggers the following actions: It smoothly transitions to the center of the screen. During this movement, it rotates by 180 degrees, revealing a blank green back content. Once the card r ...

Is there a way to position the twitter embed at the center of a webpage?

I am attempting to embed a Twitter video and twit in such a manner that they are perfectly centered on the page and also take up the entire width of the container (my-container). Here is the HTML code that I currently have: <div class="my-container"&g ...

Adjusting the spacing between a pair of radio buttons within the identical group

Is there a way to adjust the spacing between two horizontal radio buttons? The buttons are part of the same group, and I want to shift the right button ("Clear Selection") further to the right so it aligns with the buttons in another group below. ...

What is the best way to insert an image that is absolutely positioned inside a <td>?

I'm facing an issue with placing an absolutely positioned image inside a td. The code I have tried seems to create gaps above the image in FF 3.6 and causes the image to disappear in IE 7. I have included the necessary external style sheet elements ab ...