如何解决如何使用Javascript打开导航栏?
当我单击3行标签时,我想查看我的导航列表。 但是当我单击它时什么也没发生。 请让我知道该怎么做。 TT 这是我写的代码。
当我单击3行标签时,我想查看我的导航列表。 但是当我单击它时什么也没发生。 请让我知道该怎么做。 TT 这是我写的代码。
随着页面缩小,出现三行标签。 而我使用的是Google chrome。
const burger = document.querySelector(".burger");
const navLinks = document.querySelector(".nav-links");
const links = document.querySelectorAll(".nav-links li");
burger.addEventListener("click",() => {
navLinks.classList.toggle("open");
});
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body{
font-family: sans-serif;
}
nav{
height: 10vh;
background: black;
}
.nav-links{
display: flex;
list-style: none;
width: 50%;
height: 100%;
justify-content: space-around;
align-items: center;
margin-left: auto;
}
.nav-links li a{
color: white;
text-decoration: none;
font-size: 16px;
}
.landing{
height: 90vh;
display: flex;
justify-content: center;
align-items: center;
}
.landing h1{
margin: 100px;
font-size: 50px;
color: purple;
}
@media screen and (max-width: 768px){
.line {
width: 30px;
height: 3px;
background: white;
margin: 5px;
}
nav{
position: relative;
}
.burger{
position: absolute;
cursor: pointer;
right: 5%;
top: 50%;
transform: translate(-5%,-50%);
}
.nav-links{
position: fixed;
background: black;
height: 100vh;
width: 100%;
flex-direction: column;
clip-path: circle(100px at 90% -20%);
-webkit-clip-path: circle(100px at 90% -20%);
transition: all 1s ease-out;
}
.nav-links.open{
clip-path: circle(1000px at 90% -20%);
-webkit-clip-path: circle(1000px at 90% -20%);
}
.landing{
flex-direction: column;
}
}
<!DOCTYPE html>
<html>
<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" />
<link href="https://fonts.googleapis.com/css2?family=Alata&display=swap" rel="stylesheet">
<title>FRIENDS</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<nav>
<div class="burger">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
<ul class="nav-links">
<li><a href="#">HOME</a></li>
<li><a href="#">CHARACTER</a></li>
<li><a href="#">STUDY</a></li>
<li><a href="#">VISITORS</a></li>
</ul>
</nav>
<section class="landing">
<img src="circle.png" alt="dots">
<h1>FRIENDS<h1>
</section>
<script type="app.js"></script>
</body>
</html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。