<!-- -------------- Created By InCoder -------------- -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animated Menu Toggle Button - InCoder</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="menu-btn">
<span></span>
<span></span>
<span></span>
</div>
<script>
let btn = document.querySelector('.menu-btn');
btn.addEventListener('click', function() {
btn.classList.toggle('active');
});
</script>
</body>
</html>
/* -------------- Created By InCoder -------------- */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.menu-btn {
width: 20rem;
height: 20rem;
display: flex;
cursor: pointer;
position: relative;
align-items: center;
border-radius: 20px;
justify-content: center;
background-color: #fff;
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.2);
}
.menu-btn span {
height: 1rem;
position: absolute;
border-radius: 8px;
background-color: #3cc091;
transition: 0.4s;
}
.menu-btn span:nth-child(1) {
left: 10%;
width: 50%;
transform: translateY(-80px);
}
.menu-btn.active span:nth-child(1) {
left: 10%;
width: 80%;
transform: translateY(0px) rotate(45deg);
}
.menu-btn span:nth-child(2) {
width: 80%;
}
.menu-btn.active span:nth-child(2) {
opacity: 0;
transform: translateX(40px);
}
.menu-btn span:nth-child(3) {
left: 10%;
width: 50%;
transform: translateY(80px);
}
.menu-btn.active span:nth-child(3) {
left: 10%;
width: 80%;
transform: translateY(0px) rotate(135deg);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.