Unable to reach the dropdown menu in CSS

Having trouble with creating a dropdown navigation bar? I've encountered an issue where the dropdown menu disappears as soon as I move my cursor off the buttons that reveal it. The menu itself displays properly, but accessing the drop down menu is proving to be problematic.

http://codepen.io/anon/pen/bNGqvp

CSS:

#navigation li {
  display:          inline;
}

/*navigation text*/
.nav a
{
    display: inline-block;
    padding: 0 20px;
    background:#383838;
    border-radius: 2em;
    border: 1px solid #272727;
    color:#C4B09C;
    text-decoration:none;
    font: bold 12px Arial;
    line-height: 27px;
    margin-right:1 px;
    position: relative;
    left: 250px;
    top: 7px; 
}


/*naviagation menu*/
.nav  {
    background: #333; 
    background: -moz-linear-gradient(#383838, #272727);
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#383838), to(#272727)); 
    background: -webkit-linear-gradient(#383838, #272727);
    border-bottom: 1px solid #222;
}




/*menu hover*/
.nav li >ul {display : none;}

.nav li:hover > ul  {
    display: block;
    position: absolute;
    padding-top: 20px;
    margin-left: 20%;
}

HTML:

   <div class="nav">
        <ul id="navigation">
            <li><a href="../index.html">Home</a></li>
            <li><a href="blog.html">Blog</a></li>
            <li><a href="#">Media</a>
                <ul>
                <li><a href="audio.html">Audio</a></li>
                <li><a href="video.html">Video</a></li>
                </ul>
            </li>
            <li><a href="#">About Me</a>
                <ul>
                <li><a href="faq.html">FAQ</a></li>
                <li><a href="contact.html">Contact</a></li>
                </ul>
            </li>
            <li><a href="honesty.html">Honesty</a></li>
        </ul>
    </div>

Answer №1

To ensure smooth navigation, simply include width: 100% in the .nav :hover section. This will allow you to hover over the navigation bar and easily click on sub-navigation items.

Tested and proven effective - see example below:

http://codepen.io/anon/pen/VYwpdN

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

Placement of text is incorrect on certain react cards

I have an application that retrieves videos and generates a card for each video, displaying the video title, creator, link, download option, views, and upload date on each card. Fetching and displaying these elements works well, for the most part. However ...

Turn off sticky sidebar feature for mobile-friendly layout

I have encountered an issue with my script that I need assistance with. I am trying to disable this script for responsive or mobile view, but despite trying various methods, it is not functioning as expected. <script type="text/javascript"> $(func ...

What is the best way to utilize *ngFor for looping in Angular 6 in order to display three images simultaneously?

I have successfully added 3 images on a single slide. How can I implement *ngFor to dynamically load data? <carousel> <slide> <img src="../../assets/wts1.png" alt="first slide" style="display: inline-blo ...

Tips for shuffling the sequence of EJS variables

I am currently working on creating a quiz that consists of multiple choice questions. In order to display the Question, Correct Answer, and 3 other wrong options, I am utilizing EJS variables. The format will be similar to the following example: Question: ...

I need help figuring out how to mention an id using a concatenated variable in the jquery appendTo() method

Using jQuery, I am adding HTML code to a div. One part of this code involves referencing a div's ID by concatenating a variable from a loop. $(... + '<div class="recommendations filter" id="recCards-'+ i +'">' + &apo ...

Is it possible to automatically adjust the text color based on the dynamic background color?

While browsing Palantir.com, I noticed that the logo color always changes to be the inverse of the background color behind it as the background scrolls or changes. https://i.sstatic.net/BYvZa.png I'm currently working on a website using Wordpress an ...

Struggling with connecting relative hyperlinks

When constructing a website, I have opted to use relative hyperlinks. The file structure is organized as follows: /root/website1/ All my code resides within the website1 folder. Within website1, the structure looks like this: /css style.css /static ...

Mastering the art of extracting elements from an HTML Dygraph

Attempting to extract all data points from this particular website utilizing BeautifulSoup and requests in Python. The current code in progress is as follows: session = requests.Session() page = session.get(https://bitinfocharts.com/comparison/bitcoin-tra ...

What is the best way to eliminate excess spacing between HTML td and table elements in Outlook?

Here's the HTML email code snippet. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Co ...

Explore and target elements using browser inspection

Is it possible to create a new CSS class using browser inspection that contains new hover/focus styles? For example: .CanIDo { /*some css rules (ex.)*/ width: 100; } /*my question (USING BROWSER INSPECTOR, not directly typing in the CSS file)*/ .CanI ...

A guide on using jQuery to cycle through every row of every table on an HTML page

I am trying to figure out the correct syntax for nesting two loops within each other in jQuery. The first loop should iterate over each table in an HTML page that does not have any IDs or classes, while the second loop should go through each table row of t ...

What is the best way to create 2 select boxes that will disable each other if they match, and then automatically choose the second option so they do not match

Is there a way to have 2 select boxes automatically change one option to the second option on one box when they match? Instead of using an "alert", I am looking for a function that can automatically update one option in one of the select boxes if they mat ...

Display a pop-up window upon clicking anywhere on the webpage using jQuery and HTML

Is it possible for me to create a pop-up window that opens a specific website when a user clicks anywhere on the page, similar to pop-up companies? Can this be achieved using HTML, JavaScript, and jQuery? Any help would be greatly appreciated. ...

Execute HTML code within a text field

Is it possible to run html code with javascript inside a text box, similar to w3schools.com? I am working solely with html and javascript. Thank you. For example, I have two text areas - one for inserting html, clicking a button to run the code, and displ ...

Accessing the selected value from a dropdown list filled with data from a PHP array in HTML

My HTML and PHP code consists of a select dropdown that looks like this: <select name="category" id="_category" class="_cateogry" onchange="submitTheForm() > option value="">Please select</option> <?php foreach ($categories as $cont ...

Deleting list items by clicking a button

I'm working on adding a functional "x" button to each list item (li) so that users can click on it to remove the item. I've successfully added the button, but I'm unsure about what code to use in the onClick event to delete the corresponding ...

Troubleshooting a navigation problem with DNN and Bootstrap-3 specifically for mobile devices

Here are the steps to demonstrate this issue: 1. Visit the following page of the website: 2. Resize your browser window to mobile size and close the menu using the icon. After the animation finishes, the navigation items reappear. I have been struggling ...

Using the cordova-plugin-file to access and play video files stored on an external SD

I am in need of assistance with displaying an image and playing a video file from the root directory of an external SD card in my Cordova wrapped HTML project. I couldn't find a suitable place to ask these questions on the GitHub page for the cordova- ...

A guide on accessing the href attribute of an HTML tag using jQuery

My goal is to extract the ID from the href attribute of an a tag on my webpage. First, I need to prevent the page from refreshing before performing this task. The example a tags look like this: '<a href="/ArtPlaces/Delete/5">Delete</a>&ap ...

"Utilizing FileReader to seamlessly integrate data into FormData without the risk

Currently, I'm in the process of constructing an ajax file uploader. This is made possible thanks to the recently introduced FormData interface. Everything seems to work as expected when using the original file. However, I encounter issues when conver ...