【发布时间】:2019-09-22 14:52:57
【问题描述】:
我遇到了一个问题,即我的导航栏中的链接不可点击,除非我删除了一些已添加的 CSS。
这是我需要删除的 CSS 的 sn-p 以获得可点击的链接:
.main-nav {
float: right;
list-style: none;
margin-top: 30px;
}
它似乎与float: right; 相关,因为如果我只禁用该短语,链接就会变得可点击。
{
margin: 0;
padding: 0;
}
header {
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url(zomb2.PNG);
height: 100vh;
background-size: cover;
background-position: center;
}
.main-nav {
float: right;
list-style: none;
margin-top: 30px;
}
.main-nav li {
display: inline-block;
}
.main-nav li a {
color: white;
text-decoration: none;
padding: 5px 20px;
font-family: "Roboto", sans-serif;
font-weight: bold;
}
.main-nav li.active {
border: 1px solid white;
}
.main-nav li a:hover {
border: 1px solid white;
}
.logo {
width: 150px;
height: auto;
float: left;
color: white;
font-size: 20px;
}
body {
font-family: monospace;
}
.row {
max-width: 1200px;
margin: auto;
}
.hero {
position: absolute;
width: 1200px;
margin-left: 0px;
margin-top: 0px;
}
h1 {
color: white;
text-transform: uppercase;
font-size: 70px;
text-align: center;
margin-top: 275px;
}
h2 {
color: white;
text-transform: uppercase;
font-size: 35px;
text-align: center;
}
.button {
margin-top: 30px;
margin-left: 440px;
}
.btn {
border: 1px solid white;
padding: 10px 30px;
color: white;
text-decoration: none;
margin-right: 5px;
font-size: 13px;
text-transform: uppercase;
}
.btn-one {
background-color: darkorange;
font-family: "Roboto", sans-serif;
}
.btn-two {
background-color: darkorange;
font-family: "Roboto", sans-serif;
}
.btn-two: hover {
background-color: darkorange;
}
<header>
<div class="row">
<div class="logo">
</div>
<ul class="main-nav">
<li class="active"><a href="">Home</a></li>
<li><a href="about.html">Learn More</a></li>
<li><a href="zombies.html">Real Zombies</a></li>
<li><a href="ordinance.html">Guns and Ammo</a></li>
<li><a href="news.html">The Latest</a></li>
<li><a href="faq.html">FAQ</a></li>
</ul>
</div>
<div class="hero">
<h1> Real Zombie Vs. Human Battles </h1>
<h2> Choose your side..</h2>
<div class="button">
<a href="" class="btn btn-one">Zombies</a>
<a href="" class="btn btn-two">Humans</a>
</div>
</div>
提前感谢您的帮助!我确定我错过了一些简单的东西,但我在任何地方都找不到它。我在这里四处搜索,找不到任何专门解决这个问题的东西。救命!
【问题讨论】:
-
尝试使用 z-index。希望有帮助
-
.hero { z-index: -1; }