什么阻止导航栏出现以及如何修复它?

问题描述 投票:0回答:3

在我的网站上完成,导航栏不起作用,虽然我一直在尝试使用我知道的每种技术来找出原因。我使用过z-index,但它也没用。

/*Header*/
header{
    background:#35424a;
    color: #ffffff;
    padding-top: 10px;
    min-height: 70px;
    border-bottom: #e8491d 3px solid;
}
 
header a{
    color: #ffffff;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 16px;
}
 
header li{
    float: right;
    display: inline;
    padding: 0 20px 0 20px;
}
 
header #branding{
    float: left;
}
 
header #branding h1{
    margin-left: 10px;
}
 
header nav{
    float: right;
    margin-top: 10px;
}
 
header ul{
    float: right;
}
 
header ul li{
    float: right;
    list-style: none;
    position: relative;
}
 
header ul li a{
    display: block;
    font-family: arial;
    font-size: 14px;
    padding:22px 14px;
    text-decoration:none;
}
 
header ul li ul{
    display: none;
    position: absolute;
    background-color: #e8491d;
    padding:10px;
    border-radius: 0px 0px 4px 4px;
}
 
header ul li:hover ul{
    display: inline-block;
    z-index: -1;
}
 
header ul li ul li{
    width: 180px;
    border-radius: 4px;
}
header ul li ul li a:hover {
    background-color: #f3f3f3;
}
header ul li ul li a{
    padding: 8px 14px;    
}
 
header .highlight, header .current a{
    color: #e8491d;
    font-weight:bold;
}
 
header a:hover{
    color: #cccccc;
    font-weight:bold;
}
 
/*Showcase*/
#showcase{
    min-height: 400px;
    background:url("https://www.mexticket.com/wp-content/uploads/2016/10/telon.jpg")no-repeat 0 -400px;
    background-position: 50% 100%;
    text-align: center;
    color: white;
}
 
#showcase h1{
    margin-top: 100px;
    font-size: 55px;
    margin-bottom: 10px;
}
 
#showcase p{
    font-size: 20px;
}
 
/*Boxes*/
#boxes{
    margin-top: 20px;
    background-color: #808080;
}
 
#boxes .box{
    float: left;
    text-align: center;
    width: 23%;
    padding: 10px;
}
 
#boxes .box img{
    width: 200px;
    height: 125px;
}
 
/*Boxes01*/
#boxes01{
    margin-top: 20px;
    background-color: #808080;
}
 
#boxes01 .box{
    float: left;
    text-align: center;
    width: 23%;
    padding: 10px;
}
 
#boxes01 .box img{
    width: 130px;
}
.box img {
    border-radius: 4px;
}
/*Information*/
.template{
background-color: #fff;
color: black;
font-family: "Arial", "Helvetica";
font-size: 12px;
}
 
.information{
margin: 0%;
padding: 0%;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>ES Torsberg</title>
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <script type="js/scripts.js"></script>
</head>
 
<body>
  <header>
    <div class="container">
      <div id="branding">
        <h1><span class="highlight">ES</span>TORSBERG</h1>
      </div>
      <nav>
        <ul>
          <li class="current"><a href="index.html">Hemma</a></li>
          <li><a href="kontakt.html">Kontakt</a></li>
          <li><a href="schema.html">Schema</a></li>
          <li><a href="omOss.html">Om Oss</a></li>
          <li>
            <a>Inriktningar
            <ul>
              <li><a href="teater.html">Teater</a></li>
              <li><a href="musik.html">Musik</a></li>
              <li><a href="dans.html">Dans</a></li>
              <li><a href="ljudteknik.html">Ljudteknik</a></li></a>
            </ul>
          </li>
         </ul>
      </nav>
    </div>
  </header>
 
  <section id="showcase">
    <div class="container">
      <h1>ESTETISKA PROGRAMMET TORSBERGSGYMNASIET</h1>
    </div>
  </section>
 
  <section id="boxes">
    <div class="container">
      <div class="box">
        <h3>TEATER</h3><a href="teater.html"><img src="IMAGES/Hemsida 6.jpg"></a>
      </div>
      <div class="box">
        <h3>MUSIK</h3><a href="musik.html"><img src="IMAGES/Hemsida 18.jpg"></a>
      </div>
      <div class="box">
        <h3>DANS</h3><a href="dans.html"><img src="IMAGES/Hemsida 10.jpg"></a>
      </div>
      <div class="box">
          <h3>LJUDTEKNIK</h3><a href="ljudteknik.html"><img src="https://cdn.pixabay.com/photo/2016/11/19/13/01/audio-1839162_960_720.jpg"></a>
      </div>
    </div>
  </section>
 
  <section id="boxes01">
    <div class="container">
      <div class="box">
        <h3>INTERVJU MED MAX</h3><a href="intervju-med-max.html"><img src="IMAGES/Max.jpg"></a>
      </div>
      <div class="box">
        <h3>INTERVJU MED ANJA</h3><a href="intervju-med-anja.html"><img src="IMAGES/anja.jpg"></a>
      </div>
      <div class="box">
        <h3>INTERVJU MED MIKAELA</h3><a href="intervju-med-mikaela.html"><img src="IMAGES/Max.jpg"></a>
      </div>
      <div class="box">
        <h3>INTERVJU MED LENA</h3><a href="intervju-med-lena.html"><img src="IMAGES/anja.jpg"></a>
      </div>
    </div>
  </section>
 
  <section class="template">
    <table class="information">
    <tbody>
      <td>
        <h1 class="information1">Telefonnummer: 010-454 10 00 <br>Skolwebbsidan: torsbergsgymnasiet.se<br>Skoladress: Läroverksgatan 36, 821 33 Bollnäs</h1>
      </td>
    </tbody>
  </table>
  </section>
 
  <footer>
    <p>ES TORSBERGSGYMNASIET | Design by Tilemachos Marmaras | Copyright &copy; 2019</p>
  </footer>
 
</body>
</html>
javascript css html5 css3 navigationbar
3个回答
1
投票

您的HTML代码结构不合理,<a><ul>之前关闭,尝试更新它:

  <li>
    <a>Inriktningar</a>
    <ul>
      <li><a href="teater.html">Teater</a></li>
      <li><a href="musik.html">Musik</a></li>
      <li><a href="dans.html">Dans</a></li>
      <li><a href="ljudteknik.html">Ljudteknik</a></li>
    </ul>
  </li>

要显示导航,请使用z-index:10;

header ul li{
    float: right;
    list-style: none;
    position: relative;
    z-index:10;
}

试试这个小提琴:https://jsfiddle.net/6rg3tqyu/


0
投票

你差不多完成了,只需从css行号中的ul中删除或更新z-index属性。 61。

header ul li:hover ul{
display: inline-block;
z-index: 1;

}


0
投票
header a{
    color: #ffffff;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 16px;
}

这会覆盖你的a链接到白色的颜色,所以你无法看到它们。

© www.soinside.com 2019 - 2024. All rights reserved.