Creating Magical menu Bar By Using HTML, CSS & JavaScript
This tutorial will guide you through Creating Magical menu Bar By Using HTML, CSS & JavaScript. Follow all the given step :
Step 1 : Create Index.html and add given html code on it.
Step 2 : Create style.css and add given css code on it.
Step 3 : Create index.js and add given js code on it.
HTML
HTML Code for Magical menu Bar
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stylish Menu</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section>
<div class="main">
<div id="design1" class="design menu_1" style="translate: 120px 120px;"></div>
<div id="design2" class="design menu_2" style="translate: 0px 120px;"></div>
<div id="design3" class="design menu_3" style="translate: -120px 120px;"></div>
<div id="design4" class="design menu_4" style="translate: 120px;"></div>
<div id="demo" class="design center_menu"></div>
<div id="design6" class="design menu_6" style="translate: -120px;"></div>
<div id="design7" class="design menu_7" style="translate: 120px -120px;"></div>
<div id="design8" class="design menu_8" style="translate: 0 -120px;"></div>
<div id="design9" class="design menu_9" style="translate: -120px -120px;"></div>
</div>
</section>
</body>
</html>
CSS
CSS Code for Magical menu Bar
*{
margin: 0;
padding: 0;
}
body{
margin: 0;
padding: 0;
}
section{
z-index: -99999999;
width: 100%;
height: 100vh;
background-color: dodgerblue;
display: flex;
justify-content: center;
align-items: center;
}
.main{
z-index: 99;
width: 350px;
height: 350px;
display: grid;
gap: 10px;
grid-template-columns: auto auto auto;
}
.design{
z-index: -9;
background-color: rgba(253,253,253,0.548);
transition: 0.5s ease;
background-size: 35%;
background-position: center;
background-repeat: no-repeat;
border-radius: 20px;
}
.center_menu{
z-index: 1;
background-color: rgb(255,255,255);
transform-origin: 10px 10px;
background-image: url(./img/settings.png);
}
.menu_1{
background-image: url(./img/edit.png);
}.menu_2{
background-image: url(./img/fingerprint.png);
}.menu_3{
background-image: url(./img/paper-plane.png);
}.menu_4{
background-image: url(./img/settings-sliders.png);
}.menu_6{
background-image: url(./img/share.png);
}.menu_7{
background-image: url(./img/video-camera-alt.png);
}.menu_8{
background-image: url(./img/shopping-cart.png);
}.menu_9{
background-image: url(./img/home.png);
}
.design:hover{
filter: invert(90%);
cursor: pointer;
}
JavaScript
JavaScript code for Magical menu Bar
bit = 1;
function myFunction() {
if(bit)
{
document.getElementById("design1").style.translate = "0px 0px";
document.getElementById("design2").style.translate = "0px 0px";
document.getElementById("design3").style.translate = "0px 0px";
document.getElementById("design4").style.translate = "0px 0px";
document.getElementById("design6").style.translate = "0px 0px";
document.getElementById("design7").style.translate = "0px 0px";
document.getElementById("design8").style.translate = "0px 0px";
document.getElementById("design9").style.translate = "0px 0px";
}
else
{
document.getElementById("design1").style.translate = "120px 120px";
document.getElementById("design2").style.translate = "0px 120px";
document.getElementById("design3").style.translate = "-120px 120px";
document.getElementById("design4").style.translate = "120px 0px";
document.getElementById("design6").style.translate = "-120px 0px";
document.getElementById("design7").style.translate = "120px -120px";
document.getElementById("design8").style.translate = "0px -120px";
document.getElementById("design9").style.translate = "-120px -120px";
}
bit = !bit;
}
document.getElementById("demo").onclick = function() {myFunction();}
What is HTML
HTML, or HyperText Markup Language, is the standard markup language used to create and design documents on the World Wide Web. It's essentially the backbone of web pages, providing the structure and content that web browsers interpret and display.
HTML consists of a series of elements, which are enclosed by tags to define their purpose and function on a webpage. These elements can include headings, paragraphs, images, links, lists, forms, and more. By using a combination of HTML elements, web developers can organize and present information in a structured and visually appealing manner.
HTML is not a programming language but rather a markup language. This means it doesn't have the capability to perform calculations or execute complex logic like programming languages do. Instead, HTML focuses on describing the structure and content of a document, leaving the presentation and functionality to other technologies like CSS (Cascading Style Sheets) for styling and JavaScript for interactivity.
In summary, HTML serves as the foundation for building web pages, providing the structure and content necessary for browsers to render and display information to users on the internet.
What is CSS
CSS, or Cascading Style Sheets, is a language used to style the presentation of web documents written in HTML and XML. It provides a way to control the layout, colors, fonts, and other visual aspects of a webpage, enabling developers to create attractive and responsive designs. By separating content from presentation, CSS promotes cleaner code, easier maintenance, and greater flexibility in website design. With CSS, developers can achieve consistent branding, improved user experience, and better accessibility across various devices and screen sizes.
What is JavaScript
JavaScript is a versatile programming language used for creating dynamic and interactive web content. It enables developers to manipulate HTML elements, respond to user actions, and build seamless web applications. With its extensive ecosystem of libraries and frameworks, JavaScript powers both client-side and server-side development, making it an essential tool for modern web development.