Animated Menu Icon Create Using Html, CSS, JS Only
HTML
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>Click on the Menu Icon to transform it to "X":</p>
<div class="container" onclick="myFunction(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
<div class="content">
<h2>SUBSCRIBE TO MD TECH TAMIZHA</h2>
<h2>THANK YOU FOR WATCHING</h2>
</div>
<script>
function myFunction(x) {
x.classList.toggle("change");
}
</script>
</body>
</html>
CSS
body{
margin: 0;
padding: 0;
background-color: rgb(100, 93, 93);
}
.container {
background-color: rgb(100, 93, 93);
position: absolute;
left: 50%;
top: 50%;
cursor: pointer;
}
p{
color: white ;
text-align: center;
margin-top: 250px
}
.bar1, .bar2, .bar3 {
width: 35px;
height: 5px;
background-color: rgb(255, 255, 255);
margin: 6px 0;
transition: 0.4s;
}
.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-9px, 6px);
transform: rotate(-45deg) translate(-9px, 6px);
}
.change .bar2 {opacity: 0;}
.change .bar3 {
-webkit-transform: rotate(45deg) translate(-8px, -8px);
transform: rotate(45deg) translate(-8px, -8px);
}
.content{
position: absolute;
left: 35%;
bottom: 20%;
}
.content h2{
text-align: center;
color: white;
}
No comments:
Post a Comment