
Hi, welcome here in this tutorial we are going to develop a mobile menu, a CSS-only project so let’s start it.
Here is your index.html file, copy the code below and paste it into index.html.
<!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>Mobile menu</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<input type="checkbox" class="toggle" id="toggle" checked="checked" />
<label for="toggle" class="toggle">Tilt it</label>
<div class="menu">
<div class="top">
<span class="search">
<input type="text">
</span>
<a href="#" class="exit" tabindex="0"></a>
</div>
<ul class="middle">
<li tabindex="0">Google</li>
<li tabindex="0">Facebook</li>
<li tabindex="0">Twitter</li>
<li tabindex="0">LinkedIn</li>
<li tabindex="0">Instagram</li>
<li tabindex="0">Amazon</li>
<li tabindex="0">Netflix</li>
<li tabindex="0">Meta</li>
</ul>
<div class="bottom"></div>
<div class="menu-back"></div>
</div>
</div>
</body>
</html>
HTMLHere is your code for the App.css file:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
body{
height: 100vh;
display:grid;
place-items:center;
background-image: linear-gradient(135deg, #43a1f8 10%, #671dc7 100%);
}
.btn{
position: relative;
width: 250px;
height: 80px;
display: grid;
place-items: center;
background-image: linear-gradient(135deg, rgb(117, 29, 189) 10%, rgb(30, 138, 210) 100%);
color: white;
border-radius: 80px;
font-size: 1.5rem;
font-weight: 700;
letter-spacing: 1px;
text-decoration: none;
border-top: 2px solid #e6e6fa;
border-left: 2px solid #e6e6fa;
padding-left: 60px;
overflow: hidden;
transition: 0.5s ease-in-out;
}
.btn:hover{
padding-left: 0px;
padding-right: 60px;
color: white;
}
.btn span {
position: absolute;
display: grid;
place-items: center;
left: 5px;
width: 70px;
height: 70px;
background-image: linear-gradient(135deg, rgb(200, 200, 200), rgb(250, 250, 250));
color: #000;
border-radius: 50%;
font-size: 2rem;
font-weight: bolder;
transition: 0.5s cubic-bezier(0.4, 0, 1, 1);
}
.btn:hover span{
left: calc(100% - 76px);
}
.btn:after{
position: absolute;
content: "";
width: 80px;
height: 100%;
z-index: 1;
background: rgb(255, 255, 255, 0.4);
transform: translateX(-175px) skew(25deg);
transition: 0.75s ease-in-out;
}
.btn:hover::after {
transform: translateX(175px) skew(25deg);
}
CSSAfter writing the code into the files (don’t forget to save it ?,) and then open your HTML file in the browser.