HTML
<div class="menu-wrapper">
<button class="toggle-button" id="menu-toggle">MENU</button>
<nav class="text-slide-menu" id="text-slide-menu">
<a href="#">TOP</a>
<a href="#">ABOUT</a>
<a href="#">WORKS</a>
<a href="#">CONTACT</a>
</nav>
</div>
CSS
.menu-wrapper {
position: relative;
text-align: center;
margin-top: 40px;
}
.toggle-button {
background: #222;
color: #fff;
padding: 14px 28px;
border: none;
border-radius: 30px;
font-size: 1rem;
font-weight: bold;
cursor: pointer;
transition: background 0.3s ease;
}
.toggle-button:hover {
background: #555;
}
.text-slide-menu {
position: absolute;
top: 60px;
left: 50%;
transform: translateX(-50%) translateY(-10px);
opacity: 0;
pointer-events: none;
display: flex;
flex-direction: column;
gap: 10px;
transition: all 0.3s ease;
z-index: 10;
}
.text-slide-menu.open {
transform: translateX(-50%) translateY(0);
opacity: 1;
pointer-events: auto;
}
.text-slide-menu a {
background: #111;
color: #fff;
padding: 10px 16px;
border-radius: 20px;
text-decoration: none;
font-size: 0.9rem;
}
.text-slide-menu a:hover {
background: #f44336;
}
JavaScript
const toggleBtn = document.getElementById("menu-toggle");
const menu = document.getElementById("text-slide-menu");
toggleBtn.addEventListener("click", () => {
menu.classList.toggle("open");
toggleBtn.textContent = menu.classList.contains("open") ? "CLOSE" : "MENU";
});