After trying numerous approaches, I am seeking help again. I have managed to create a dropdown menu, but now I'm wondering how to add a transition effect to it. Any suggestions on what changes I should make are greatly appreciated. Below is the code snippet:
$(document).on("click", ".menuButton", function () {
$(".dropdown").toggleClass("visible");
});
#menuDiv {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.menuButton {
text-align: center;
}
.dropdown {
display: block;
width: 100%;
visibility: hidden;
transition: visibility 300ms ease-in-out;
}
.visible {
visibility: visible;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="index.js" defer></script>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div id='menuDiv'>
<button class='menuButton'>Menu <i class="fa-solid fa-angle-down"></i></button>
<div id='dropdownmenu'>
<button class='dropdown lunch'>Lunch</button>
<button class='dropdown dinner'>Dinner</button>
<button class='dropdown locations'>Locations</button>
</div>
</div>
</body>
</html>