Я пытаюсь создать бургер. Он отлично работает, но мне нужно добавить кое-что еще на Javascript, дело в том, что я новичок, и я понятия не имею о javascript. Мне было интересно, можете ли вы мне помочь.
Мне нужно это , когда я кликаю c на любом элементе, меню закрывается и X превращается в обычный бург
const menuIcon = document.querySelector('.burger');
const navbar = document.querySelector('nav');
const body = document.querySelector('body');
menuIcon.addEventListener('click', () => {
navbar.classList.toggle('change');
});
menuIcon.addEventListener('click', () => {
menuIcon.classList.toggle('change');
});
menuIcon.addEventListener('click', () => {
body.classList.toggle('change');
});
*{
margin:0;
padding:0;
font-family: 'Open Sans', sans-serif;
}
html{
scroll-behavior: smooth;
}
body{
width:100%;
}
.change{
overflow-y:hidden;
}
header{
height: 15vh;
background-color:#000;
display: flex;
align-items: center;
position: fixed;
width:100%;
z-index: 100;
top:0;
}
header nav{
transition: 0.4s;
}
header p{
font-size: 25px;
font-weight: bold;
color:#dfe6e9;
padding:20px 40px;
}
header .burger{
position:absolute;
right:2%;
display: block;
z-index: 100;
}
header .burger div{
transition: all .2s;
background-color: #fff;
}
header nav ul{
margin-top:50px;
}
.change{
right:0;
}
.change .line1{
transform: rotate(-45deg) translate(-5px, 5px);
background-color: #d63031;
}
.change .line2{
opacity: 0;
}
.change .line3{
transform: rotate(45deg) translate(-5px, -5px);
background-color: #d63031;
}
header nav ul li{
display:block;
margin: 0px 16px;
padding:30px 0px 0px 15px;
text-align: center;
}
header nav ul li a{
font-size:20px;
font-family: "Open Sans";
padding:10px 5px;
color:#fff;
letter-spacing: 0px;
transition:.4s;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 2px;
}
header nav ul li a:hover{
color: #d63031;
/* background-color:#dfe6e9; */
/* border-radius: 20px; */
/* padding:10px 15px; */
}
header .burger{
width:22px;
display: block;
position: fixed;
right:0%;
padding: 0px 15px 1px 9px;
}
header .burger .line2, .line3{
margin-top: 4px;
}
header .burger .line1, .line2, .line3{
width:100%;
height:3px;
border-radius: 1px;
}
.part1{
background: url(valentins2.jpg) no-repeat;
background-size: auto 101%;
background-position: center;
}
h1{
font-family: 'Montserrat';
font-size: 45px;
font-weight: 900;
text-transform: uppercase;
color: #ff7675;
text-align: center;
margin:0px 0px 30px 0px;
padding-top: 90px;
}
.box1 p{
font-size:16px;
color:#fff;
text-align: center;
margin: 0px auto 30px auto;
width:90%;
}
.box1 .buttn{
margin: 40px auto 0px auto;
padding-bottom: 50px;
}
.box1 .buttn a{
text-decoration: none;
text-transform: uppercase;
letter-spacing: 3px;
padding: 10px 35px;
background-color: #ff7675;
color: #fff;
font-weight:700;
transition:.4s;
border-radius: 20px;
}
.box1 .buttn a:hover{
background-color: #dfe6e9;
font-weight: 900px;
color:#d63031;
}
.box2, .box4{
width:100%;
height:105vh;
background-color:#222326;
display:flex;
justify-content: center;
text-align: center;
position: relative;
}
.delineador{
border-top: 2px solid white;
width:85px;
border-radius: 1px;
position:absolute;
top:31%;
}
#third{
position:absolute;
top:40%;
}
h2{
text-transform: uppercase;
text-decoration: none;
font-size: 29px;
font-weight:800;
width:90%;
font-family:"Montserrat";
color: #fff;
transition: .4s;
position: absolute;
top:7%;
}
.box2 p, .box3 p{
font-size: 16px;
color:#fff;
position:absolute;
top:45%;
width:90%;
margin-bottom:30px;
}
.box2 a{
font-size: 16px;
color:#fff;
text-decoration: none;
position:absolute;
bottom:12%;
margin: 0px 15px;
padding:10px 15px;
border-radius: 4px;
background-color: #636e72;
}
.box2 i{
position:absolute;
bottom: 0%;
right:87%;
font-size: 18px;
background-color:#636e72;
padding: 12px 10px;
border-radius: 4px;
}
.box2 i:hover, a:hover{
color:#fab1a0;
}
.box3{
width:100%;
height:70vh;
display:flex;
justify-content: center;
text-align: center;
position: relative;
}
.part2{
background: url(valentins33.jpg) no-repeat;
background-size:auto 101%;
background-position: center;
}
.mail{
position: absolute;
top:52%;
}
.mail a{
font-size: 16px;
color:#ff7675;
text-decoration: none;
}
.mail a:hover{
color:#fab1a0;
}
.icon-group{
display:flex;
justify-content: center;
text-align: center;
position: absolute;
bottom:19%;
}
.icon-group a{
font-size: 26px;
background-color: #636e72;
border-radius: 100%;
color:#fff;
text-decoration: none;
}
.icon-group a:hover{
color:#fab1a0;
}
#ig{
padding:10px 12px;
}
#fb{
padding:10px 15px;
}
#tw{
font-size: 23px;
padding: 12px;
margin:0px 35px;
}
footer{
width:100%;
height: 6vh;
background-color: #636e72;
display:flex;
justify-content: center;
align-items: center;
}
footer p{
font-size: 14px;
color:#fff;
padding: 0px 15px;
}
@media only screen and (min-width:1023px){
header{
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
}
header nav{
display:inline;
position:absolute;
right: 2%;
background-color: none;
}
header nav ul li{
display:inline;
margin: 0px 14px;
}
header nav ul{
margin-top:0;
}
header nav ul li a{
font-size:14px;
font-weight: 600;
font-family: 'Open Sans';
padding:10px 0px;
color:#dfe6e9;
letter-spacing: 0px;
transition:.4s;
text-transform: uppercase;
text-decoration: none;
}
header nav ul li a:hover{
color: #d63031;
/* background-color:#dfe6e9; */
border-radius: 20px;
/* padding:10px 15px; */
}
header .burger{
display:none;
}
h1{
width: 30%;
padding: 0px 40px;
text-align: left;
font-size: 55px;
padding-top:114px;
}
.box1 p{
width:38%;
text-align: left;
margin:0;
padding: 0px 40px;
}
.box1 .buttn{
margin:40px 0px 0px 0px;
padding:0px 40px 40px 40px;
}
.box2,.box4{
height: 70vh;
}
.box2 p,.box4 p{
width:60%;
}
.box3 p{
width:60%;
}
#third{
top:35%;
}
#tw{
margin:0px 45px;
}
}
@media only screen and (min-width:732px){
.part1,.part2{
background-size: 100% auto;
}
}
@media only screen and (max-width:1023px){
header nav{
position:fixed;
top:0;
right: -100%;
background-color:#000;
z-index: 100;
width: 100%;
height: 100vh;
}
header{
margin-bottom: 22px;
height: 54px;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Ballon bouquet</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:600,800,900|Open+Sans:400,500,600,700,800,900&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/f7c1027ae7.js" crossorigin="anonymous"></script>
</head>
<body>
<article class="part1" id="scroll1">
<header>
<p>Fantasy Ballons</p>
<nav>
<ul>
<li><a class="lis" data-scroll href="#scroll1">Home</a></li>
<li><a class="lis" data-scroll href="#scroll2">Shop</a></li>
<li><a class="lis" data-scroll href="#scroll3">About us</a></li>
<li><a class="lis" data-scroll href="#scroll4">Contact us</a></li>
</ul>
</nav>
<div class="burger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</header>
<section class="box1">
<h1>Online Shopping</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam
,quis nostrud exercitatiasdfasdfadfon ullamco laboris nisi </p>
<p class="buttn"> <a href="http://www.balloonbouquet.com.mialias.net/">Buy Now</a></p>
</section>
</article>
<section class="box2" id="scroll2">
<h2>Discover our promotions</h2>
<div class="delineador"></div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim </p>
<a href="http://www.balloonbouquet.com.mialias.net/">Check out! <i class="fas fa-cart-arrow-down"></i></a>
</section>
<article class="part2" id="scroll3">
<section class="box3">
<h2>Who are we?</h2>
<div class="delineador"></div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim </p>
</section>
</article>
<section class="box4" id="scroll4">
<h2>Follow us on social networks!</h2>
<div class="delineador" id="third"></div>
<p class="mail"><a href="#">Fantasyballoonsmn@gmail.com</a></p>
<div class="icon-group">
<a href="https://www.instagram.com/fantasyballoonsmn/?igshid=4tjmhgygzn34&fbclid=IwAR2ery7dREwZsVODZa9hv-gv9e6aWkq6Kt8WrEci1snxH7mwHpM-YaWvLx4" title="Instagram"<i class="fab fa-instagram" id="ig"></i></a>
<a href="#" title="Twitter"<i class="fab fa-twitter" id="tw"></i></a>
<a href="https://www.facebook.com/fantasyballoonsmn/" title="Facebook"<i class="fab fa-facebook-f" id="fb"></i></a>
</div>
</section>
<footer>
<p>Copyright © 2020 Fantasyballoonsmn</p>
</footer>
<script src="app.js"></script>
</body>
</html>
er, то же самое, что когда вы кликаете c на X. Не могли бы вы сказать мне строки кода, которые мне нужно добавить на мой css и js файлы для этого? Я действительно ценю это