How to create a Menu Icon using CSS ?
Last Updated :
28 Apr, 2025
The Menu Icon is mostly used on smaller screens, there's limited space to display a full navigation menu. A menu icon helps in hiding the navigation items initially and revealing them when the user needs them. In this article, we will see how To Create a Menu Icon using CSS.
There are many ways to create a Menu Icon using CSS. The article contains two ways including a simple menu icon and an animated menu icon.
In this approach, we will design a simple menu icon with the help of CSS properties by incorporating three horizontal lines and designing it most simply and attractively.
Approach
- First create the basic structure of the project using different elements including <div>, <h1>, and <h3>.
- For creating a simple menu icon with three horizontal bars there are three <div> elements defined in the HTML file.
- Give them styling with different CSS properties like height, margin, width, and background color.
- At last use other CSS properties like box-shadow and flexbox properties to give a pleasing effect to the menu icon.
Example: The example shows how To Create a Menu Icon using different flexbox properties.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,
initial-scale=1.0">
<title>Menu Icon using CSS</title>
<link rel="stylesheet"
href="index.css">
</head>
<body>
<div class="box1">
<h1>GeeksforGeeks</h1>
<h3>How To Create a
Menu Icon using CSS
</h3>
<div class="box">
<div class="div1 menu"></div>
<div class="div2 menu"></div>
<div class="div3 menu"></div>
</div>
</div>
</body>
</html>
CSS
@import url(
'https://fonts.googleapis.com/css2?family=Poppins&display=swap');
.menu {
height: 7px;
margin: 3px;
width: 50px;
background-color: green;
border-radius: 10px;
}
.box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 70px;
width: 80px;
border: 2px solid black;
border-radius: 20px;
box-shadow: rgba(74, 62, 62, 0.45) 0px 7px 19px;
}
.box1 {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
font-family: 'Poppins', sans-serif;
}
h1 {
color: green;
}
Output:

In this approach, we will design a animated menu icon with the help of CSS properties by incorporating three horizontal lines and adding animation in such way that whenever user hover on menu icon it changes to cross icon smoothly via transform property.
Approach
- First create the basic structure of the project using different elements including <div>, <h1>, and <h3>.
- For creating a simple menu icon with three horizontal bars there are three <div> elements defined in the HTML file. Give them styling with different CSS properties like height, margin, width, and background color.
- There are other CSS properties are used as well like box-shadow, flexbox properties for giving a pleasing effect to the menu icon.
- For animation transform property is defined for class menubar1 and class menubar3. Set opacity to 0 for class menubar2.
Example: The example shows how To Create a Menu Icon with animation.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,initial-scale=1.0">
<link rel="stylesheet"
href="index.css">
</head>
<body>
<div class="box1">
<h1>GeeksforGeeks</h1>
<h3>
How To Create a Menu
Icon using CSS
</h3>
<div class="box">
<div class="menubar menubar1"></div>
<div class="menubar menubar2"></div>
<div class="menubar menubar3"></div>
</div>
</div>
</body>
</html>
CSS
@import url(
'https://fonts.googleapis.com/css2?family=Poppins&display=swap');
.menubar {
height: 7px;
width: 50px;
background-color: green;
border-radius: 10px;
margin: 7px;
transition: 0.7s;
}
.box:hover>.menubar1 {
transform: translate(0, 14px) rotate(40deg);
background-color: red;
}
.box:hover>.menubar2 {
opacity: 0;
}
.box:hover>.menubar3 {
transform: translate(0, -14px) rotate(-40deg);
background-color: red;
}
.box {
height: 60px;
width: 60px;
border: 2px solid black;
border-radius: 20px;
padding-top: 5px;
box-shadow: rgba(74, 62, 62, 0.45) 0px 7px 19px;
}
.box1 {
display: flex;
align-items: center;
height: 100vh;
justify-content: center;
flex-direction: column;
font-family: 'Poppins', sans-serif;
}
h1 {
color: green;
}
Output:

Similar Reads
How to create a mega menu using HTML and CSS ? HTML is a markup language used to create web pages and CSS is a stylesheet language used to design a document written in a markup language such as HTML. In this article, we are going to know how can we create a mega menu on our web page with the help of only HTML and CSS. Mega menus are a type of ex
4 min read
How to create Vertical Menu using HTML and CSS ? In This article, we will learn how to create vertical menus by using HTML and CSS. Vertical Menu: We can create a vertical menu in the form of buttons and a scrollable menu. Vertical Menu is the buttons arranged in the vertical menu bar/navbar. How to create a vertical menu using buttons: We can cre
2 min read
How to Create Nested Sub Menu using CSS ? CSS Nested Sub-Menus refers to Dropdown Menus that are contained within another dropdown menu. These are commonly used in navigation menus to organize and structure content hierarchically. In this article, we are going to build a nested sub-menu using CSS, it will consist of a nav bar with various l
3 min read
How to create Radial Menu in CSS ? There are so many ways to create a radial menu by using the CSS property. The font icon, letters, and or image are used in the radial menu. That radial button can be linked with the sites. Set the position, height, and width of a radial button by using CSS. There is another approach using JavaScript
3 min read
How to Create an Image Overlay Icon using HTML and CSS ? Image overlay Icon can be an impressive addition to interactive detail or a set of features for your website. This article content will divide the task into two sections, the first section creating the structure and attach the link for the icon. In the second section, we will design the structure us
3 min read