The content on this website, including videos and code examples, is for educational purposes only. All demonstrations and designs are fictional and created to illustrate coding techniques. Any resemblance to existing websites or brands is purely coincidental.
The creators and administrators of this website do not claim ownership or affiliation with any existing websites or companies. Users are encouraged to use the information responsibly for learning purposes. Liability for any misuse of the content provided is not accepted.
Below is the html code for this video.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shrink Expand Menu</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="navbar">
<input type="checkbox" id="menu-checkbox" class="hamburger">
<div class="menu-content">
<ul class="nav-items">
<li class="nav-item"><a href="#home"><span class="nav-item-text">Home</span></a></li>
<li class="nav-item"><a href="#features"><span class="nav-item-text">Features</span></a></li>
<li class="nav-item"><a href="#about"><span class="nav-item-text">About</span></a></li>
<li class="nav-item"><a href="#contact"><span class="nav-item-text">Contact</span></a></li>
</ul>
</div>
<label for="menu-checkbox" class="menu-close-btn"></label>
</div>
</body>
</html>
Below is the css code for this video.
style.css
*, *::after, *::before {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
width: 100%;
overflow: hidden;
}
body::after, body::before {
content: "";
display: block;
height: 50%;
background: #0073cf;
}
body::after {
background: #00bfff;
}
.navbar {
position: absolute;
top: 50%;
left: 50%;
height: 90px;
width: auto;
background: #f0f8ff;
border-radius: 8px;
margin-top: -45px;
transform: translate3d(-50%, 0, 0);
box-shadow: 0 10px 28px #003153;
overflow: hidden;
}
.hamburger {
position: absolute;
left: 0;
top: 0;
pointer-events: none;
z-index: -10;
opacity: 0;
}
.menu-content {
position: relative;
height: 100%;
width: 90px;
transition: width 1s cubic-bezier(0.5, -0.5, 0.75, 1.25);
}
.hamburger:checked~.menu-content {
width: 410px;
transition: width 1s cubic-bezier(0.5, 0.5, 0.25, 1.5);
}
.nav-items {
position: relative;
height: 100%;
width: 410px;
padding-left: 20px;
padding-right: 110px;
list-style-type: none;
font-size: 0;
}
.nav-item {
display: inline-block;
width: 70px;
color: #003153;
font-size: 16px;
line-height: 90px;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
vertical-align: top;
cursor: pointer;
transition: color 0.5s, transform 0.5s;
}
.nav-item a {
color: inherit;
text-decoration: none;
}
.nav-item:hover {
color: #00bfff;
transform: scale(1.1);
}
.nav-item-text {
display: block;
height: 100%;
transform: rotateY(-70deg);
opacity: 0;
transition: transform 0.75s cubic-bezier(0.5, 0.5, 0.75, 2.5), opacity 0.75s;
}
.hamburger:checked~.menu-content .nav-item-text {
transform: rotateY(0deg);
opacity: 1;
transition: transform 0.75s cubic-bezier(0.5, 0.5, 0.75, 2.5), opacity 0.25s;
}
.nav-item:nth-child(1) .nav-item-text {
transition-delay: 0.3s;
}
.hamburger:checked~.menu-content .nav-item:nth-child(1) .nav-item-text {
transition-delay: 0s;
}
.nav-item:nth-child(2) .nav-item-text {
transition-delay: 0.2s;
}
.hamburger:checked~.menu-content .nav-item:nth-child(2) .nav-item-text {
transition-delay: 0.1s;
}
.nav-item:nth-child(3) .nav-item-text {
transition-delay: 0.1s;
}
.hamburger:checked~.menu-content .nav-item:nth-child(3) .nav-item-text {
transition-delay: 0.2s;
}
.nav-item:nth-child(4) .nav-item-text {
transition-delay: 0s;
}
.hamburger:checked~.menu-content .nav-item:nth-child(4) .nav-item-text {
transition-delay: 0.3s;
}
.menu-close-btn {
position: absolute;
top: 0;
right: 0;
height: 90px;
width: 90px;
padding: 35px 30px;
cursor: pointer;
}
.menu-close-btn::after, .menu-close-btn::before {
content: "";
display: block;
height: 4px;
width: 28px;
background: #0073cf;
border-radius: 2px;
transform-origin: 50% 50%;
transition: transform 1s cubic-bezier(0.5, 0.5, 0.25, 1.25), background 0.5s;
}
.menu-close-btn::before {
margin-bottom: 10px;
}
.menu-close-btn:hover::after, .menu-close-btn:hover::before {
background: #00bfff;
}
.hamburger:checked~.menu-close-btn::before {
transform: translateY(7px) rotate(-225deg);
}
.hamburger:checked~.menu-close-btn::after {
transform: translateY(-7px) rotate(225deg);
}
Thanks for visiting