1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
<HTML>
<HEAD>
<TITLE>
Test de dropdown menu
</TITLE>
<style>
/* Dropdown Button */
.dropbtn {
color: black;
/*padding: 16px;*/
font-size: 16px;
border: none;
cursor: pointer;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
left: 30px;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
/* 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 {
background-color: #cde
}
/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
.show {
display:block;
}
</style>
</HEAD>
<BODY>
<div class="dropdown">
<a href="#" onclick="myFunction('myDropdown1')" class="dropbtn">Dropdown</a>
<div id="myDropdown1" class="dropdown-content">
<a href="#2">Link 1</a>
<div class="dropdown">
<a href="#" onclick="myFunction('myDropdown3')" class="dropbtn">Link1.1</a>
<div id="myDropdown3" class="dropdown-content">
<a href="#2">Link 1.2</a>
</div>
</div>
<a href="#3">Link 2</a>
<a href="#1">Link 3</a>
</div>
</div>
<div class="dropdown">
<a href="#" onclick="myFunction('myDropdown2')" class="dropbtn">Link</a>
<div id="myDropdown2" class="dropdown-content">
<a href="#2">Link 4</a>
<a href="#3">Link 5</a>
<a href="#1">Link 6</a>
</div>
</div>
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction(dropDownLink) {
document.getElementById(dropDownLink).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');
}
}
}
}
</script>
</BODY> |
Partager