Tips for creating a floating dropdown menu using CSS

I'm really struggling to figure this out! I want the drop-down tabs in my top navigational menu on my website to slide down gracefully when hovered over, rather than just instantly appearing. The effect I'm aiming for is similar to this example:

Here's the CSS code I currently have for my drop-down menu:

nav ul ul {
    display: none;
    z-index: 9999
}

nav ul li:hover > ul {
    display: block;
}
nav ul {
    background: #efefef; 
    background: linear-gradient(top, #D8D8D8 10%, #D0D0D0 90%);  
    background: -moz-linear-gradient(top, #D8D8D8 10%, #D0D0D0 90%);
    background: -webkit-linear-gradient(top, #D8D8D8 10%, #D0D0D0 90%);
    box-shadow: 0px 0px 9px 0px rgba(0,0,0,0.15);
    padding: 0px 20px;
    border-radius: 10px;  
    list-style: none;
    position: relative;
    display: inline-table;
}
nav ul:after {
    content: "";
    clear: both;
    display: block;
}
li {
    float: left;
}
nav ul li:hover {
    background: #4b545f;
    background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
    background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);
    background: -webkit-linear-gradient(top, #4f5964 0%, #5f6975 40%);
}
nav ul li:hover a {
    color: #fff;
}

nav ul li a {
    display: block;
    padding: 10px 40px;
    color: #757575;
    text-decoration: none;
    font-family:arial;
}
nav ul ul {
    background: #5f6975;
    border-radius: 0px;
    padding: 0px;
    position: absolute;
    top: 100%;
}
nav ul ul li {
    float: none; 
    border-top: 1px solid #6b727c;
    border-bottom: 1px solid #575f6a;
}
nav ul ul li a {
    padding: 10px 40px;
    color: #fff;
    font-family:arial;
    font-weight:900;
}   
nav ul ul li a:hover {
    background: #4b545f;
}
nav ul ul ul {
    position: absolute;
    left: 100%;
    top:0;
}

This is the HTML code that I insert into my webpages:

<center><nav>
<ul>
    <li><a href="/">Home</a></li>
    <li><a href="">Arcade</a>
        <ul>
            <li><a href="/arcade/action">Action</a></li>
            <li><a href="/arcade/arcade">Arcade</a></li>
            <li><a href="/arcade/puzzle">Puzzle</a></li>
            <li><a href="/arcade/vehicle">Vehicle</a></li>
            <li><a href="/arcade/violence">Violence</a></li>
            <li><a href="/arcade/defense">Defense</a></li>
            <li><a href="/arcade/rpg">RPG</a></li>
        </ul>
    </li>
    <li><a href="">Watch</a>
        <ul>
            <li><a href="/watch/tv">TV Shows</a></li>
            <li><a href="/watch/movies">Movies</a></li>
        </ul>
    </li>
    <li><a href="">Extras</a>
        <ul>
            <li><a href="/news">News</a></li>
            <li><a href="/updates">Updates</a></li>
        </ul>
    </li>
    <li><a href="/support">Support</a></li>
</ul>
</nav></center>

Do you have any suggestions on how I could accomplish this?

You can visit my website at

Answer №1

Check out the underlying code of the sample website you shared - it leverages CSS transform to create that particular visual effect.

Answer №2

nav ul ul li {
display: inline-block;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
}

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

Breaking or wrapping lines in Visual Studio Code

While working in Visual Studio Code, I often encounter the issue of long lines extending beyond the screen edge instead of breaking and wrapping to the next line. This lack of text wrapping can be quite bothersome. I utilize a split-screen setup on my co ...

How to use jQuery to toggle a specific div within a PHP loop

In my PHP code, I have a while loop that echos rows inside a div acting like a button. When this button is clicked, I want to hide/show the connected div using jQuery's "toggle" function. Currently, when any button is clicked, all divs open instead of ...

Retrieve information from the identical registration form in Codeigniter

https://i.stack.imgur.com/FWTIf.png The student registration form includes fields for father and mother information in the student table, while guardian information is stored in a separate guardians table. When selecting "Father" in the "Guardian Informat ...

Is there a way to adjust the border color of my <select> element without disrupting the existing bootstrap CSS styling?

In my Bootstrap (v4.5.3) form, the select options appear differently in Firefox as shown in the image below: https://i.sstatic.net/3suke.png Upon form submission, I have JavaScript code for validation which checks if an option other than "-- Select an Op ...

How to position a "figure" element at the center using CSS creatively (without relying on Div elements)

Struggling with my first website creation, I encountered a challenge in centering three inline-block images using CSS. Despite successfully using the figure tag to title and display the images, I couldn't get them to align horizontally from the cente ...

Angular2: Leveraging click events to manage CSS classes on elements

I am currently developing a web app using Angular 2. I'm facing an issue where the active element should receive an extra CSS class when clicked, but adding the ":active" CSS attribute with a custom class doesn't work as expected. The ":focus" pr ...

Creating responsive CSS layouts for various device sizes

My webpage features a form with a prompt for the input box, followed by the input box itself. I want to implement two different layouts based on the device accessing the page. For cell phones, I want everything stacked vertically. However, for computers, ...

Is it possible to incorporate a CSS3 transition into the styling of a list of images?

Looking to achieve a CSS3 linear transition for a "list-style-image" specifically for Firefox? You'll need to include "-moz-" in your code. -moz-transition: list-style-image 0.2s linear; However, the above code is not producing the desired result. I ...

StorageLimit: A new condition implemented to avoid saving repetitive values in the localStorage

Is there a way to store the text of an li element as a localStorage value only once when clicked? If it already exists in localStorage, a second click should have no effect other than triggering an alert. I'm currently using an if statement inside a ...

Loading textures in three.js using css sprites

I am currently utilizing var texture1 = THREE.ImageUtils.loadTexture("image1.jpg"); in order to apply this texture to a material. I am wondering if it is possible to load textures using CSS, as I would like to implement images through CSS sprites. Th ...

Only output to the console if the data returned from an AJAX request has been

Here is a script that I created: <script type="text/javascript> $('.storage').html(""); setInterval(function(){ $.get('./playcommand.php', function(data) { if($('.storage').html() !== data){ ...

Chrome is inaccurately reporting the outerHeight value, while IE and FireFox are displaying it correctly

The jquery.smartWizard plugin includes a function called fixHeight that adjusts the height of a wizard step. It is utilized when displaying a step for the first time or revealing hidden divs within the step. The function works correctly in IE and FireFox, ...

The horizontal scroll feature is dysfunctional when attempting to allocate cell space based on a percentage

I want to display two sections of text that take up the full width of the screen and resize automatically when the screen size changes. Currently, I am using percentage widths to achieve this. However, when the text inside a section exceeds the available ...

Issues with Vue.js table component functionality

I have created a table where each tbody item is a component structured like this: <div class="panel"> <table class="table"> <thead> <tr> <th>Door</th> <th>Van</th> ...

Adjust the content of an iframe based on the size of the screen

Hi there, I'm currently facing an issue with an ad that can't be resized. The support team suggested using two different ads - one for mobile and one for desktop. The dimensions of the ads are 720 x 90 and 300 x 100. I would like the ad to automa ...

Is there a way to navigate to a specific div when clicking on it?

Need help with scrolling after running code function scrollFunction() { document.getElementById('insert').scrollIntoView(); } I have a button that triggers some code and I want the page to scroll afterwards. Currently, it scroll ...

Leveraging the power of beautifulsoup and selenium for web scraping on a multi-page site results in gathering a

I am in the process of scraping text from a website iteratively. Each page on this particular website follows the same html structure. I utilize selenium to go to the next page each time I add the following strings: text_i_want1, text_i_wantA, text_i_wantB ...

Is it possible to merge CSS transitions and animations?

Hi there, I'm encountering an issue when trying to combine CSS transitions and animations. It seems that when I add a transition, it cancels out the animation that is working. Does anyone have any insights on how to successfully merge them together? ...

In IE8, the :last-child pseudo-class appears to be ineffective

Here is the HTML structure I am working with: <div class="footerMenu"> <ul> <li>Home</li> <li>About</li> <li>Feedback</li> <li>Contact us</li> </ul> ...

How can you navigate to different pages in Chrome by selecting radio buttons that are designed as clickable

Currently, I am in the process of developing a website for my job and I have come across a dilemma with two radio button options. To make the text and radio buttons function as links that redirect users to specific pages within the website, I utilized < ...