- How TO — Hoverable Dropdown
- Dropdown
- Create A Hoverable Dropdown
- Example
- Example Explained
- Example
- Example Explained
- 26 CSS Dropdown Menus
- Related Articles
- Author
- Links
- Made with
- About a code
- Dropdown Dark/Light
- Author
- Links
- Made with
- About a code
- Gooey Dropdown Menu
- Author
- Links
- Made with
- About a code
- Drop Down Menu
- Author
- Links
- Made with
- About a code
- Navigation with Sub-Navigation
- Author
- Links
- Made with
- About a code
- Pure CSS Dropdown Menu
- Author
- Links
- Made with
- About a code
- The More Menu
- Author
- Links
- Made with
- About the code
- Drop Down Menu
- Author
- Links
- Made with
- About the code
- Molten Menu
- Author
- Links
- Made with
- About the code
- HTML & CSS Dropdown Menu
- Author
- Links
- Made with
- About the code
- Gradient Menu
- Author
- Links
- Made with
- About the code
- Main Menu
- Author
- Links
- Made with
- About the code
- CSS Menu
- Author
- Links
- Made with
- About the code
- CSS Dropdown Menu
- Author
- Links
- Made with
- About the code
- Horizontal Dropdown Menu
- Author
- Links
- Made with
- About the code
- Dropdown Menu
- Author
- Links
- Made with
- About the code
- Fancy Menu
- Author
- Links
- Made with
- About the code
- Recursive Hover Navigation
- Author
- Links
- Made with
- About the code
- Cool Dropdown Menu Effects
- Author
- Links
- Made with
- About the code
- CSS Dropdown Menu
- Author
- Links
- Made with
- About the code
- Dropdown Menu
- Author
- Links
- Made with
- About the code
- Simple Pure CSS Dropdown Menu
- Author
- Links
- Made with
- About the code
- Simple Pure CSS Dropdown Menu
- Author
- CSS Dropdowns
- Example
- Example Explained
- Dropdown Menu
- Example
- Create Dropdown Menu Using HTML and CSS
- Dropdown Menu Using Only HTML and CSS Project Preview👇
- CSS Code For Dropdown Menu:-
- Final Output Of Dropdown Menu Using CSS:
- Live Preview Of Dropdown Menu:-
- Which code editor do you use for Dropdown Menu coding?
- What is a drop-down Menu?
- What is the purpose of drop down menu?
How TO — Hoverable Dropdown
Learn how to create a hoverable dropdown menu with CSS.
Dropdown
A dropdown menu is a toggleable menu that allows the user to choose one value from a predefined list:
Create A Hoverable Dropdown
Create a dropdown menu that appears when the user moves the mouse over an element.
Step 1) Add HTML:
Example
Example Explained
Use any element to open the dropdown menu, e.g. a , or
element.
Use a container element (like ) to create the dropdown menu and add the dropdown links inside it.
Wrap a element around the button and the to position the dropdown menu correctly with CSS.
Step 2) Add CSS:
Example
/* Dropdown Button */
.dropbtn background-color: #04AA6D;
color: white;
padding: 16px;
font-size: 16px;
border: none;
>
/* The container — needed to position the dropdown content */
.dropdown position: relative;
display: inline-block;
>
/* Dropdown Content (Hidden by Default) */
.dropdown-content display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
>
/* Links inside the dropdown */
.dropdown-content a color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
>
/* Change color of dropdown links on hover */
.dropdown-content a:hover
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn
Example Explained
We have styled the dropdown button with a background-color, padding, etc.
The .dropdown class uses position:relative , which is needed when we want the dropdown content to be placed right below the dropdown button (using position:absolute ).
The .dropdown-content class holds the actual dropdown menu. It is hidden by default, and will be displayed on hover (see below). Note the min-width is set to 160px. Feel free to change this. Tip: If you want the width of the dropdown content to be as wide as the dropdown button, set the width to 100% (and overflow:auto to enable scroll on small screens).
Instead of using a border, we have used the box-shadow property to make the dropdown menu look like a «card». We also use z-index to place the dropdown in front of other elements.
The :hover selector is used to show the dropdown menu when the user moves the mouse over the dropdown button.
26 CSS Dropdown Menus
Collection of hand-picked free HTML and CSS dropdown menu code examples from codepen and other resources. Update of July 2019 collection. 9 new items.
Related Articles
Author
Links
Made with
About a code
Dropdown Dark/Light
Pure CSS dropdown dark/light.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Gooey Dropdown Menu
Compatible browsers: Chrome, Edge, Opera, Safari
Author
Links
Made with
About a code
Drop Down Menu
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Navigation with Sub-Navigation
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Pure CSS Dropdown Menu
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
The More Menu
Using clip-path times two to make an irregular shaped object fill out a cut-out shape in an unfold open menu effect.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Drop Down Menu
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Molten Menu
This combines a CSS drop down menu, and the oozing effects of liquid flame.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
HTML & CSS Dropdown Menu
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Gradient Menu
Responsive gradient dropdown menu.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Main Menu
Horizontal menu with dropdown effects in HTML and CSS.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
CSS Menu
No JS — be sure to check out the mobile menu.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
CSS Dropdown Menu
HTML and CSS dropdown menu with nice effect.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Horizontal Dropdown Menu
Pure CSS horizontal dropdown menu with nice transitions and beautiful palette.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Dropdown Menu
Cool HTML & CSS dropdown menu.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Fancy Menu
Fancy dropdown menu in HTML and CSS. Inspired by https://dribbble.com/shots/1075480-Ui-Kit-Hotel
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Recursive Hover Navigation
Only CSS recursive hover nav.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Cool Dropdown Menu Effects
Cool dropdown menu pure CSS effects.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
CSS Dropdown Menu
Full CSS dropdown navigation. Drops down on click by the use of a hidden checkbox.
Author
Links
Made with
About the code
Dropdown Menu
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Simple Pure CSS Dropdown Menu
Menu with dropdown made only in CSS, with a line that follow the hover on the line.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Simple Pure CSS Dropdown Menu
Simple, sleek looking dropdown menu effect achieved using pure CSS. Simple functionality, method can be extended to create a secondary dropdown block with few edits.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
CSS Dropdowns
Create a dropdown box that appears when the user moves the mouse over an element.
Example
.dropdown-content display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
>
.dropdown:hover .dropdown-content display: block;
>
Example Explained
HTML) Use any element to open the dropdown content, e.g. a , or a element.
Use a container element (like ) to create the dropdown content and add whatever you want inside of it.
Wrap a element around the elements to position the dropdown content correctly with CSS.
CSS) The .dropdown class uses position:relative , which is needed when we want the dropdown content to be placed right below the dropdown button (using position:absolute ).
The .dropdown-content class holds the actual dropdown content. It is hidden by default, and will be displayed on hover (see below). Note the min-width is set to 160px. Feel free to change this. Tip: If you want the width of the dropdown content to be as wide as the dropdown button, set the width to 100% (and overflow:auto to enable scroll on small screens).
Instead of using a border, we have used the CSS box-shadow property to make the dropdown menu look like a «card».
The :hover selector is used to show the dropdown menu when the user moves the mouse over the dropdown button.
Dropdown Menu
Create a dropdown menu that allows the user to choose an option from a list:
This example is similar to the previous one, except that we add links inside the dropdown box and style them to fit a styled dropdown button:
Example
/* The container — needed to position the dropdown content */
.dropdown position: relative;
display: inline-block;
>
/* Dropdown Content (Hidden by Default) */
.dropdown-content display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
>
/* Links inside the dropdown */
.dropdown-content a color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
>
/* Change color of dropdown links on hover */
.dropdown-content a:hover
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content display: block;
>
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn background-color: #3e8e41;
>
Create Dropdown Menu Using HTML and CSS
Hello Coder! Welcome to the Codewithrandom blog. In this blog, we learn how to create a Dropdown Menu Using HTML and CSS. When you hover over the link in the navbar its shows a dropdown menu on links hover.
We use Html for creating the Structure of the Dropdown Menu by creating a navbar And Use Css for styling the Dropdown menu.
Dropdown Menu Using Only HTML and CSS Project Preview👇
A “dropdown” menu resembles a list of choices but is concealed within a button or other element. When the user clicks on the button, the dropdown menu is revealed. This blog post will discuss how to make a sidebar dropdown menu using HTML and JavaScript.
Do you want to learn HTML to JavaScript? 🔥
If yes, then here is our Master Frontend: Zero to Hero eBook! 📚 In this eBook, you’ll learn complete HTML, CSS, Bootstrap, and JavaScript from beginner to advance level. 💪 It includes 450 Projects with source code.
CSS Code For Dropdown Menu:-
@import url(https://fonts.googleapis.com/css?family=Open+Sans); @import url(https://fonts.googleapis.com/css?family=Bree+Serif); body < background: #ebf0f5; font-size: 22px; line-height: 32px; color: #ffffff; word-wrap: break-word !important; font-family: "Open Sans", sans-serif; >a < color: #fff; >#container < margin: 0 auto; >nav < margin: 50px 0; background-color: #0f131f; >nav ul < padding: 0; margin: 0; list-style: none; position: relative; >nav ul li < display: inline-block; background-color: #0f131f; >nav a < display: block; padding: 0 10px; color: #fff; font-size: 20px; line-height: 60px; text-decoration: none; >nav a:hover < background-color: #5f5c5c; >nav ul ul < display: none; position: absolute; top: 60px; >nav ul li:hover > ul < display: inherit; >nav ul ul li < width: 170px; float: none; display: list-item; position: relative; >nav ul ul ul li < position: relative; top: -60px; left: 170px; >h1 < width: 670px; color: black; font-size: 1.4rem; >li > a:after < content: " +"; >li > a:only-child:after
Step1:Using the Google import link, we will first add a few new typeface styles to our drop-down menu. The two new font families Open Sans and Bree Brif will be added to our effort.
The background will now be set to a light blue using the body tag selector, and the font size property will be used to set the typeface height to “22 px.” We will add a line height of 32 pixels using the line height attribute, and the font color is set to white.
@import url(https://fonts.googleapis.com/css?family=Open+Sans); @import url(https://fonts.googleapis.com/css?family=Bree+Serif); body
Step2:Using the tag identifier (a,nav), we will now set the background property to “black,” the margin to 5 opx, and the colour to “white.” We will also set the margin using the navbar tag selector.
By using the “a” tag selector, we will also set the display as “block” and the font height as 20px for our drop-down menu as we set the position as inline block for it.
Also using the hover property we will add an hover as the user hover over the navbar link the background color changes of the icon sd “Gray color”.
< color: #fff; >#container < margin: 0 auto; >nav < margin: 50px 0; background-color: #0f131f; >nav ul < padding: 0; margin: 0; list-style: none; position: relative; >nav ul li < display: inline-block; background-color: #0f131f; >nav a < display: block; padding: 0 10px; color: #fff; font-size: 20px; line-height: 60px; text-decoration: none; >nav a:hover < background-color: #5f5c5c; >nav ul ul < display: none; position: absolute; top: 60px; >nav ul li:hover > ul < display: inherit; >nav ul ul li < width: 170px; float: none; display: list-item; position: relative; >nav ul ul ul li < position: relative; top: -60px; left: 170px; >h1 < width: 670px; color: black; font-size: 1.4rem; >li > a:after < content: " +"; >li > a:only-child:after
Now we have completed our Html and Css Code
Final Output Of Dropdown Menu Using CSS:
Live Preview Of Dropdown Menu:-
Here is our updated output with Html and Css. Hope you like Dropdown Menu Project. you can see the output video and project screenshots. See our other blogs and gain knowledge in front-end development.
In this post, we learn how to create a Dropdown Menu Using HTML and CSS. If we made a mistake or any confusion, please drop a comment to reply or help you in easy learning.
Written by – Code With Random/Anki
Which code editor do you use for Dropdown Menu coding?
I personally recommend using VS Code Studio, it’s straightforward and easy to use.
What is a drop-down Menu?
A “dropdown” menu looks like a collection of options but is actually hidden inside a button or other element. The drop-down menu is displayed after the user selects the button. In this blog article, we’ll talk about creating a sidebar dropdown menu with HTML and JavaScript.
What is the purpose of drop down menu?
A drop-down menu’s primary function is to condense a lot of data and links into a small space. This aids in website administration and makes it easy for users to access key links, which improves user experience.