Drop down menus html code

Содержание
  1. How TO — Clickable Dropdown
  2. Dropdown
  3. Create a Clickable Dropdown
  4. Example
  5. Example Explained
  6. Example
  7. Example Explained
  8. Example
  9. 26 CSS Dropdown Menus
  10. Related Articles
  11. Author
  12. Links
  13. Made with
  14. About a code
  15. Dropdown Dark/Light
  16. Author
  17. Links
  18. Made with
  19. About a code
  20. Gooey Dropdown Menu
  21. Author
  22. Links
  23. Made with
  24. About a code
  25. Drop Down Menu
  26. Author
  27. Links
  28. Made with
  29. About a code
  30. Navigation with Sub-Navigation
  31. Author
  32. Links
  33. Made with
  34. About a code
  35. Pure CSS Dropdown Menu
  36. Author
  37. Links
  38. Made with
  39. About a code
  40. The More Menu
  41. Author
  42. Links
  43. Made with
  44. About the code
  45. Drop Down Menu
  46. Author
  47. Links
  48. Made with
  49. About the code
  50. Molten Menu
  51. Author
  52. Links
  53. Made with
  54. About the code
  55. HTML & CSS Dropdown Menu
  56. Author
  57. Links
  58. Made with
  59. About the code
  60. Gradient Menu
  61. Author
  62. Links
  63. Made with
  64. About the code
  65. Main Menu
  66. Author
  67. Links
  68. Made with
  69. About the code
  70. CSS Menu
  71. Author
  72. Links
  73. Made with
  74. About the code
  75. CSS Dropdown Menu
  76. Author
  77. Links
  78. Made with
  79. About the code
  80. Horizontal Dropdown Menu
  81. Author
  82. Links
  83. Made with
  84. About the code
  85. Dropdown Menu
  86. Author
  87. Links
  88. Made with
  89. About the code
  90. Fancy Menu
  91. Author
  92. Links
  93. Made with
  94. About the code
  95. Recursive Hover Navigation
  96. Author
  97. Links
  98. Made with
  99. About the code
  100. Cool Dropdown Menu Effects
  101. Author
  102. Links
  103. Made with
  104. About the code
  105. CSS Dropdown Menu
  106. Author
  107. Links
  108. Made with
  109. About the code
  110. Dropdown Menu
  111. Author
  112. Links
  113. Made with
  114. About the code
  115. Simple Pure CSS Dropdown Menu
  116. Author
  117. Links
  118. Made with
  119. About the code
  120. Simple Pure CSS Dropdown Menu
  121. Author
  122. How TO — Hoverable Dropdown
  123. Dropdown
  124. Create A Hoverable Dropdown
  125. Example
  126. Example Explained
  127. Example
  128. Example Explained
  129. HTML Drop-down Menu – How to Add a Drop-Down List with the Select Element
  130. How to Create an HTML Dropdown List
  131. How to Create a Hover-able Drop-down Menu
  132. Wrapping Up

How TO — Clickable Dropdown

Learn how to create a clickable dropdown menu with CSS and JavaScript.

A dropdown menu is a toggleable menu that allows the user to choose one value from a predefined list:

Create a Clickable Dropdown

Create a dropdown menu that appears when the user clicks on a button.

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: #3498DB;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
>

/* 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 (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
.show

Example Explained

We have styled the dropdown button with a background-color, padding, hover effect, 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).

Читайте также:  Php curl authorisation header

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.

Step 3) Add JavaScript:

Example

/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() document.getElementById(«myDropdown»).classList.toggle(«show»);
>

// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) if (!event.target.matches(‘.dropbtn’)) var dropdowns = document.getElementsByClassName(«dropdown-content»);
var i;
for (i = 0; i < dropdowns.length; i++) var openDropdown = dropdowns[i];
if (openDropdown.classList.contains(‘show’)) openDropdown.classList.remove(‘show’);
>
>
>
>

Источник

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.

Author

Made with

About a code

Pure CSS dropdown dark/light.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About a code

Gooey Dropdown Menu

Compatible browsers: Chrome, Edge, Opera, Safari

Author

Made with

About a code

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About a code

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About a code

Pure CSS Dropdown Menu

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

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

Made with

About the code

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

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

Demo image: HTML & CSS Dropdown Menu

Author

Made with

About the code

HTML & CSS Dropdown Menu

Compatible browsers: Chrome, Firefox, Opera, Safari

Demo image: Gradient Menu

Author

Made with

About the code

Gradient Menu

Responsive gradient dropdown menu.

Compatible browsers: Chrome, Firefox, Opera, Safari

Author

Made with

About the code

Horizontal menu with dropdown effects in HTML and CSS.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: CSS Menu

Author

Made with

About the code

CSS Menu

No JS — be sure to check out the mobile menu.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: CSS Dropdown Menu

Author

Made with

About the code

CSS Dropdown Menu

HTML and CSS dropdown menu with nice effect.

Compatible browsers: Chrome, Firefox, Opera, Safari

Author

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

Demo image: Dropdown Menu

Author

Made with

About the code

Cool HTML & CSS dropdown menu.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: Fancy Menu

Author

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

Demo image: Recursive Hover Navigation

Author

Made with

About the code

Recursive Hover Navigation

Only CSS recursive hover nav.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: Cool Dropdown Menu Effects

Author

Made with

About the code

Cool Dropdown Menu Effects

Cool dropdown menu pure CSS effects.

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Author

Made with

About the code

CSS Dropdown Menu

Full CSS dropdown navigation. Drops down on click by the use of a hidden checkbox.

Читайте также:  Curses for python windows

Demo image: Dropdown Menu

Author

Made with

About the code

Compatible browsers: Chrome, Edge, Firefox, Opera, Safari

Demo image: Simple Pure CSS Dropdown Menu

Author

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

Demo image: Simple Pure CSS Dropdown Menu

Author

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

Источник

How TO — Hoverable Dropdown

Learn how to create a hoverable dropdown menu with CSS.

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.

Источник

HTML Drop-down Menu – How to Add a Drop-Down List with the Select Element

Joel Olawanle

Joel Olawanle

HTML Drop-down Menu – How to Add a Drop-Down List with the Select Element

Many websites, applications, and web pages use drop-down menus to help display a list of information. You can use them to create navigation menus, options for forms, and more.

If you’re looking at some of these menus or lists, you might imagine how complex creating them could be. And yes – in some cases, it gets a little bit complex.

A drop-down menu is a list of options that gets revealed vertically when a user interacts with the menu by either clicking on it or hovering over it with their cursor.

Читайте также:  Nnmclub to forum viewforum php

This menu also disappears when the user stops interacting with the menu by clicking again or taking the cursor away from the menu.

In this article, you will learn how to add a drop-down list to the select element on your webpage. You’ll also learn the various options available, and how to create a hoverable drop-down list/menu.

How to Create an HTML Dropdown List

In HTML, by default, you can always create a drop-down list with the select tag alongside the option tag. This is mainly used within forms to select a value from a list of many options.

The select tag has two primary attributes: the name and id attributes.

You use the name attribute to identify the drop-down when a selection is submitted in a form. You can connect the id attribute to a label that has similar values to its for attribute.

The select tag also has some optional boolean attributes like disabled (which disables the select fields), required (which makes the field required in a form), and lots more.

Within the select tag, you can add many options in the individual option tag. The option tag has an attribute of value that specifies a value that is submitted from the form when an option gets selected.

There are other boolean attributes like disabled (which disables the option in the menu), and selected (which you use to set a particular option as the default selected option when the page loads rather than the first option).

In the above code, the first option has an attribute of disabled , meaning you will not be able to select the option. The fourth option has an attribute of selected , meaning that instead of having JavaScript as the selected value by default, Java will be selected.

How to Create a Hover-able Drop-down Menu

When you scroll through or visit many advanced and modern webpages, you will notice that they have drop-down menus.

These menus are used for navigation to help hold similar links together. Most times, when you hover on the parent menu, then the drop-down list appears.

s_B4C6D2ADDF91C398F7D0077C06A79A5494062ED47759B85768844AD11A4B757E_1664053790313_image

You can create these types of menues in various ways, as there is no direct syntax to build one.

You can create this using CSS styling to show and hide the drop-down list when the user hovers over the menu. A very good approach is to create a div that holds the menu and the drop-down.

This div serves as a container and you can style it to a position of relative and display of inline-block , so the drop-down options appear below the menu.

You can style your button and the dropdown-options however you wish. But the major style that controls the hover effect, by default, sets the dropdown-options not to display. Then when a mouse hovers over the menu, the display is not set to block , so the options are visible. You also set the position to absolute , so the options appear below the menu, and overflow to auto to enable scroll on small screens.

.dropdown-options < display: none; position: absolute; overflow: auto; >.dropdown:hover .dropdown-options

In the demo below, we add more styling to make the drop-down menu more attractive and nice:

Wrapping Up

In this article, you have learned how to create a drop-down list with the select tag. You’ve also learned how to create the hoverable drop-down menu with CSS to handle the hover effect.

Источник

Оцените статью