为什么a:hover和href链接在我的无序css列表中不起作用?

时间:2017-03-24 06:25:34

标签: html css hover html-lists href

好的,出于某种原因我的href链接和a:hover css功能都没有用。谢谢!

还有id" mobNav"是我的移动导航所以它不应该干扰我的问题。

代码段:



nav#topTab {
  float: left;
  width: 100%;
  overflow: hidden;
}

nav#topTab ul {
  float: left;
  clear: left;
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  left: 50%;
}

nav#topTab ul li {
  display: block;
  float: left;
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  right: 50%;
}

nav#topTab ul li a {
  display: block;
  padding: 0 5% 0 5%;
  margin: 0 15% 0 3%;
  font-size: 2.2em;
  background: #fcfcfc;
  color: #000;
  text-decoration: none;
  font-family: 'Gloria Hallelujah';
}

nav#topTab ul li a:hover {
  background: #000;
  color: #fff;
  box-shadow: inset 0 0 0 3px #3a7999;
}

<nav id="topTab">
  <a href="#" id="mobNav"></a>
  <ul>
    <li><a href="http://www.example.org/" title="morning delight">morning delight</a></li>
    <li><a href="http://www.example.org/" title="yesterday">yesterday's leftovers</a></li>
    <li><a href="http://www.example.org/" title="accelaaaa">accela-meme</a></li>
  </ul>
</nav>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

原来nav标签应该包含标题元素。我将html改为:

<nav id="topTab">
        <a href="#" id="mobNav"></a>
          <ul>
              <li><a href="http://www.example.org/" title="morning delight">morning delight</a></li>
              <li><a href="wwww.google.com" title="yesterday">yesterday's leftovers</a></li>
              <li><a href="#" title="accelaaaa">accela-meme</a></li>
          </ul>

  <div>
    <img id="navRight" src = "forwardarrow.png" alt="forwards">
    <img id="navLeft" src = "backarrow.png" alt="backwards">
  </div>

  <div>
    <h1>
    <b href="http://localhost:8000/home.html" title="Home">MemeSlutz</b></h1> 
    <h2>Dank Rank</h2>
  </div>

</nav>

并在导航中包含标题,由于某种原因,悬停功能和href工作。