我的响应式导航栏不起作用,锚标记也不起作用
My responsive nav bar not working and anchor tag also
在我添加图片和段落之前,导航栏可以使用,登录也可以在移动设备上使用,但现在无法使用。它在桌面上工作。但是添加图片和段落后,导航栏和登录锚标记没有working.pls帮助
我没有更改导航和锚标记的 CSS 代码
HTML
body {
font-family: "Roboto", sans-serif;
background-color:#e3e1dc;
}
* {
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
}
nav {
background-color: orange;
height: 80px;
width:1100px;
}
nav ul {
float: left;
margin-left: 10px;
}
nav ul li {
display: inline-block;
line-height: 80px;
margin: 0 15px;
}
nav ul li a {
position: relative;
color: white;
font-size: 18px;
text-transform: uppercase;
padding: 5px 0;
}
nav ul li a:before {
position: absolute;
content: "";
left: 0;
height: 3px;
width: 100%;
bottom: 0;
transform: scaleX(0);
transform-origin: right;
background-color: white;
transition: transform 0.4s linear;
}
nav ul li a:hover:before {
transform: scaleX(1);
transform-origin: right;
}
label #btn,
label #cancel {
color: white;
font-size: 30px;
float: left;
line-height: 80px;
margin-left: 20px;
cursor: pointer;
display: none;
}
#check {
display: none;
}
.gif {
width: 1100px;
height: 300px;
}
li {
border-color:black;
}
.p {
position:absolute;
left: 800px;
top:30px;
color:white;
}
.png {
width:1200px;
height:600px;
position:absolute;
top: 250px;
right:-12.5%;
border-radius:30px;
overflow:hidden;
}
.tune {
position:relative;
top:200px;
width:900px;
left:70px;
border-radius:4px;
border:5px solid grey;
border-top:none;
background-color:white;
}
@media screen and (max-width: 960px) {
ul {
position: fixed;
height: 100vh;
width: 70%;
background-color: orange;
text-align: left;
top: 80px;
left: -100%;
transition: all 0.4s;
}
li {
position: relative;
left: 65px;
}
nav ul li {
display: block;
margin: 50px 0;
line-height: 30px;
}
label #btn {
display: block;
}
nav ul li a {
font-size: 16px;
}
#check:checked ~ ul {
left: -5%;
}
.gif {
position:relative;
width:138.5%;
height: 470px;
top:-130px;
}
nav {
width: 138.5%;
}
.p {
left:80%;
top: 30px;
color:white;
border-radius: 29px;
border-color:black;
}
.png {
width:400px;
height:300px;
position:absolute;
top: 150px;
right:-4.5%;
border-radius:30px;
overflow:hidden;
}
.tune{
width: 300px;
left: 30px;
top: -235px;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Organic Pe|Home</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="index.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="index.css" >
</head>
<body style="width:75%; max-width: 980px;" >
<nav>
<a class="p" href="../login/index.html" >Login</a>
<label for="check">
<i class="fa fa-bars" id="btn"></i>
</label>
<input type="checkbox" id="check">
<ul>
<li class="like" ><a href="#">Home</a></li>
<li class="like"><a href="#">Forums</a></li>
<li class="like"><a href="#">Store</a></li>
<li class="like"><a href="#">Vote</a></li>
<li class="like"><a href="#">Contact us</a></li>
</ul>
</nav>
<img class="gif"src="pe.png">
<div >
<img src="ann.png" class="png">
<p class="tune">
<strong>Hello Everyone</strong></br>
We are very happy to announce that we are going
to release our Skyblock server very soon and the
server will have alot of features:<br>
=>Boss fight<br>
=>Pvp fight<br>
=>Economy<br>
=>Custom skyblock<br>
=>Custom shops<br>
=>custom npc<br>
=>Events<br>
=>Giveaways<br>
and alot more<br>
<br>
Thanks,<br>
Reyyan The OWNER,
</p>
</div>
</body>
</html>
问题是您的图片超出了导航栏。
发生这种情况是因为您的图像具有赋予其“优先级”的“相对位置”。
解决这个问题的一种方法是在导航栏中添加一个位置并利用 z-index 属性 为其赋予更高的“优先级”。
希望对您有所帮助:
nav {
position: relative;
background-color: orange;
height: 80px;
width:1100px;
z-index: 111
}
在我添加图片和段落之前,导航栏可以使用,登录也可以在移动设备上使用,但现在无法使用。它在桌面上工作。但是添加图片和段落后,导航栏和登录锚标记没有working.pls帮助 我没有更改导航和锚标记的 CSS 代码 HTML
body {
font-family: "Roboto", sans-serif;
background-color:#e3e1dc;
}
* {
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
}
nav {
background-color: orange;
height: 80px;
width:1100px;
}
nav ul {
float: left;
margin-left: 10px;
}
nav ul li {
display: inline-block;
line-height: 80px;
margin: 0 15px;
}
nav ul li a {
position: relative;
color: white;
font-size: 18px;
text-transform: uppercase;
padding: 5px 0;
}
nav ul li a:before {
position: absolute;
content: "";
left: 0;
height: 3px;
width: 100%;
bottom: 0;
transform: scaleX(0);
transform-origin: right;
background-color: white;
transition: transform 0.4s linear;
}
nav ul li a:hover:before {
transform: scaleX(1);
transform-origin: right;
}
label #btn,
label #cancel {
color: white;
font-size: 30px;
float: left;
line-height: 80px;
margin-left: 20px;
cursor: pointer;
display: none;
}
#check {
display: none;
}
.gif {
width: 1100px;
height: 300px;
}
li {
border-color:black;
}
.p {
position:absolute;
left: 800px;
top:30px;
color:white;
}
.png {
width:1200px;
height:600px;
position:absolute;
top: 250px;
right:-12.5%;
border-radius:30px;
overflow:hidden;
}
.tune {
position:relative;
top:200px;
width:900px;
left:70px;
border-radius:4px;
border:5px solid grey;
border-top:none;
background-color:white;
}
@media screen and (max-width: 960px) {
ul {
position: fixed;
height: 100vh;
width: 70%;
background-color: orange;
text-align: left;
top: 80px;
left: -100%;
transition: all 0.4s;
}
li {
position: relative;
left: 65px;
}
nav ul li {
display: block;
margin: 50px 0;
line-height: 30px;
}
label #btn {
display: block;
}
nav ul li a {
font-size: 16px;
}
#check:checked ~ ul {
left: -5%;
}
.gif {
position:relative;
width:138.5%;
height: 470px;
top:-130px;
}
nav {
width: 138.5%;
}
.p {
left:80%;
top: 30px;
color:white;
border-radius: 29px;
border-color:black;
}
.png {
width:400px;
height:300px;
position:absolute;
top: 150px;
right:-4.5%;
border-radius:30px;
overflow:hidden;
}
.tune{
width: 300px;
left: 30px;
top: -235px;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Organic Pe|Home</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="index.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="index.css" >
</head>
<body style="width:75%; max-width: 980px;" >
<nav>
<a class="p" href="../login/index.html" >Login</a>
<label for="check">
<i class="fa fa-bars" id="btn"></i>
</label>
<input type="checkbox" id="check">
<ul>
<li class="like" ><a href="#">Home</a></li>
<li class="like"><a href="#">Forums</a></li>
<li class="like"><a href="#">Store</a></li>
<li class="like"><a href="#">Vote</a></li>
<li class="like"><a href="#">Contact us</a></li>
</ul>
</nav>
<img class="gif"src="pe.png">
<div >
<img src="ann.png" class="png">
<p class="tune">
<strong>Hello Everyone</strong></br>
We are very happy to announce that we are going
to release our Skyblock server very soon and the
server will have alot of features:<br>
=>Boss fight<br>
=>Pvp fight<br>
=>Economy<br>
=>Custom skyblock<br>
=>Custom shops<br>
=>custom npc<br>
=>Events<br>
=>Giveaways<br>
and alot more<br>
<br>
Thanks,<br>
Reyyan The OWNER,
</p>
</div>
</body>
</html>
问题是您的图片超出了导航栏。 发生这种情况是因为您的图像具有赋予其“优先级”的“相对位置”。 解决这个问题的一种方法是在导航栏中添加一个位置并利用 z-index 属性 为其赋予更高的“优先级”。 希望对您有所帮助:
nav {
position: relative;
background-color: orange;
height: 80px;
width:1100px;
z-index: 111
}