Navigating through a dropdown menu by utilizing the arrow keys

When hovering over the menu bar, the dropdown menus appear but I am unable to scroll down using the arrow keys. Clicking on a menu item also does not allow me to navigate through the menu with the arrow keys. It seems like this issue is related to the focus attribute.

CSS code:

.dropdown:hover > .dropdown-nav {
    display: block;
    visibility: visible;
    color: white;
    background-color: #5F5F5F;
    font-size: 11.5px;
    top: 30px;
    scrollbar-base-color: #5F5F5F;
    height: 180px;
    overflow-x: no-display;
    overflow-y: no-display;
}

#menu {
    padding: 0;
    z-index: 2;
    background-color: #5F5F5F;
    height: 60px;
    position: fixed;
    vertical-align: middle;
    margin: 60px 0 0 0;
    width: 92%;
    margin-left: 4%;
    margin-right: 4%;
    float: left;
}

.menu-size {
    font-size: 15px;
    color: white;
    text-align: left;
    display: inline;
    background-color: #5f5f5f;
    height: 60px;
    padding-bottom: 30px;
    margin-bottom: -30px;
    margin-top: 60px;
    margin-left: 0px;
    padding-top: 6px;
    width: 100px;
}

HTML Code:

 <div class="dropdown">
    <a class="menu-size" href="#">home</a>
    <ul class="dropdown-nav">
        <li><a href="index.html">about us</a></li>
        <li><a href="index.html">works published</a></li>
        <li><a href="index.html#page3">best of the best</a></li>
        <li><a href="index.html#page9">recommended links</a></li>
        <li><a href="index.html#page9">books to research</a></li>
        <li><a href="index.html#page10">links to research</a></li>
    </ul>
</div>

Answer №1

Have you considered utilizing bootstrap dropdowns? They offer a wide range of functionalities and can be easily tailored by adding other classes.

Explore the bootstrap 4 examples of dropdown menus, which even support item navigation through arrow keys.

If you are unsure about how to incorporate bootstrap into your website or project, refer to this resource

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

Angular silhouette casting on CSS fold

I am attempting to recreate this design as accurately as possible, but I am struggling with replicating the shadow effect on the right side. Is it achievable using CSS? CSS: *{margin:0px;padding:0px;} html { width:100%; height:100%; te ...

What is the best way to use multiple transparent images as backgrounds on a website using HTML?

This is the current background settings: <html> <head> <title></title> </head> <body style="background: #5d5d5d url(images/tile_dark.png); border: 20px solid #00c09e; ...

retaining the scroll position of a window when refreshing a div

There's this issue that's been bothering me lately. I update the database via an ajax call, refresh the div, everything works fine, but it still scrolls to the top of the page. Here's what I have attempted: function postdislike(pid, user, ...

Showcasing top performers via JavaScript tabs

I have two tabs on my webpage: "Overall Leaderboard" and "Weekly Leaderboard". Each tab displays a leaderboard with different scores. When I click on the "Overall Leaderboard" tab, it shows a leaderboard with specific scores. Now, my question is how can ...

Adding CSS and JavaScript files to HTML files within a Spring MVC 4 application

I'm encountering issues when trying to import my CSS files using spring 4 Initially, I attempted the following in index.html: <link href="../../resources/css/bootstrap.min.css" rel="stylesheet"> Although Eclipse did not detect any errors, th ...

What is the best way to achieve transparency in the alpha channels of my animated sprite?

Exploring the capabilities of ThreeJS through a small game project has been quite fascinating. Currently, I have an animated sprite that fits well in my scene using PlaneGeometry and a png texture in MeshBasicMaterial. However, the issue arises when the al ...

What is the reason behind jQuery(this).css('background-image') returning the browser's URL?

There are three divs in the code snippet below. <div id="div#product_img_wrapper"> <div id="product_design1" class="timage" style="z-index: 20; background-image: url('');"></div> <div id="product_design2" class="tim ...

JavaScript overlay that does not interact with HTML elements directly

Currently, I am facing the challenge of implementing a javascript overlay upon page load without direct access to the html code. My only options are to upload .js and .css files. I have extensively searched for solutions, but as someone with limited exper ...

Which event occurs first for a4j:jsFunction, reRender or oncomplete?

After running a jsFunction, I want the javascript to execute once the re-rendering is completed. I assume that the "oncomplete" javascript function is triggered after the re-rendering process, but I'm not entirely certain. Any insights on this? Appre ...

Payload content delivery system - GraphQL Error: Names must consist solely of [_a-zA-Z0-9] characters, however, "_9:00" does not meet this criteria

I've encountered a problem with Payload CMS where a GraphQL error related to enum value naming is causing issues. The problem arises with a collection named FormSubmission that includes a field called appointmentTime, which utilizes a select field typ ...

What is the best way to ensure a bottom tooltip stays perfectly aligned with the right edge of its corresponding element?

Currently, I am trying to implement a tooltip above my progress bar. However, the small tooltip that I have is not functioning correctly... This is how it currently appears: https://i.sstatic.net/ZJUyT.png I need the tooltip to display above the white d ...

Tips for retrieving a td element from an HTML document

I have a variable containing HTML data and I need to extract a specific td element from it. When I use the alert(returnData) function, it displays the following output: <tr class='addedrow'> <td id="abc">DOM-001 <inpu ...

Tips for resolving the "trim" of undefined property error in Node.js

Looking to set up a basic WebAPI using Firebase cloud functions with express and TypeScript. Here's the code I have so far: import * as functions from 'firebase-functions'; import * as express from 'express'; const app = express( ...

Divide a collection of objects into groups based on 2-hour time spans

I have an array of objects that I need to split into chunks of 2 hours each, starting on the hour (e.g. 10.00 - 12.00, 12.00 - 14.00, etc). Here is my current solution, but I feel like it may not be the most efficient: Please consider the day variable, w ...

Creating a Stylish CSS Table Utilizing DIV Elements: Preventing the Top Row from Scrolling

Utilizing a pure DIV table with the display: table, table-row, table-cell format for styling, I have managed to make the entire table scroll except for the header row. However, I am in search of methods that can prevent the header row (1st row) from scroll ...

What is the most efficient way to retrieve all documents from all parent collections in Firebase Firestore asynchronously?

My current challenge involves retrieving all the documents from every collection within a Firestore database structured as shown below: -users(collection) -user1 (document) -snippets(collection) -snippetdId1 (document) - ...

Inserting Random Data into MySQL Tables using Node.js

I am currently working on developing a game bot for Discord similar to Town of Salem, Wolvesville, Feign, and others. Within my database, I have a table called "joinedplayer" which stores users who have used the "join" command: gamerid discordid 1 ...

The challenge with linking within Layerslider

Having some trouble with an external link to a specific layerslider slide (html version, NOT wordpress). Here is the webpage in question: After reaching out in the support forum, I was advised to use this javascript: <a href="javascript:void(0);" onc ...

Steps to forward a restricted user to a specific webpage

I am currently utilizing NextJs and am in the process of creating a redirecting function for users who have been banned or blocked from accessing the DB/session. My attempt at this involved: redirect.js, where I created a custom redirect function. impo ...

Verification message appears once the SQL database has provided the necessary information to the data table

function alertbox() { var mode = document.getElementById('<%= hdnMode.ClientID %>').value; if (mode == "EDIT") return false; if (confirm("Is the same data present against that ID?") == true) { document.getElemen ...