下拉列表在菜单标题中变得混乱

时间:2017-06-03 04:57:18

标签: javascript jquery html css

我正在为我的网页制作菜单标题。这是我的jsfiddle

在我的菜单标题中,我的下拉列表在INSURANCE文字上无效。一旦你点击它,你会看到我的意思。我无法弄清楚出了什么问题。而且我认为这主要是因为height上的overflow.topnav,但不确定修复它的最佳方法是什么?

这是我的HTML和CSS:



@font-face {
  font-family: AvantGarde Demi;
  src: url(AvantGarde Demi.woff);
}
@font-face {
  font-family: AvantGarde;
  src: url(AvantGarde.woff);
}
@font-face {
  font-family: ITC Avant Garde Gothic;
  src: url(ITC Avant Garde Gothic.woff);
}
/******************For Top Nav****************************/
.topnav {
  position: relative;
  top: -890px;
  background-color: rgba(0, 0, 0, 0.5);
  height: 89px;
  border-bottom: 3px solid #EF7440;
  overflow: hidden;
}
.topnav ul>li {
  float: left;
  display: block;
  text-align: center;
  padding: 14px 16px;
}
.topnav a {
  text-decoration: none;
  font-size: 17px;
  color: white;
  display: block;
}
/* dropdown menus hidden initially */

.topnav ul > li > ul {
  display: none;
  margin-top: 30px;
  width: 200px;
  padding: 0;
  position: absolute;
  background-color: #f76c38;
}
.topnav ul > li > ul > li {
  float: left;
  clear: left;
  display: block;
  text-align: left;
}
body {
  border: 0;
  margin: 0;
  height: 100%;
  min-height: 100%;
  overflow-x: hidden;
}
.header {
  position: relative;
  height: 769px;
}
.header-background {
  height: 769px;
  width: 100%;
}
.orange-bar {
  position: relative;
  padding-left: 150px;
  top: -430px;
  left: -160px;
}
.header h1 {
  padding-left: 110px;
  color: white;
  font-family: AvantGarde;
  text-align: center;
  font-size: 35px;
  left: -420px;
  letter-spacing: .24em;
  position: relative;
  top: -615px;
  font-family: "AvantGarde";
  text-transform: uppercase;
}
.header p {
  padding-left: 290px;
  text-align: center;
  padding-right: 210px;
  font-size: 22px;
  letter-spacing: .12em;
  font-family: "Adelle PE";
  color: white;
  position: relative;
  top: -700px;
}
.header h2 {
  font-family: "Adelle PE";
  font-style: italic;
  text-transform: uppercase;
  top: -490px;
  font-weight: normal;
  font-size: 21px;
  position: relative;
  margin-left: 630px;
  color: white;
  letter-spacing: 0.24em;
}
.header a {
  color: white;
  text-decoration: none;
}
#worldofnorthman {
  background-size: cover;
  background-image: url("our_story.png");
  /*width: 404px;*/
  height: 768px !important;
}
.login {
  display: inline;
  padding-left: 15px;
  letter-spacing: .25em;
  color: white;
  font-size: 11.433px;
  font-family: AvantGarde;
}
.login a {
  color: white;
  text-decoration: none;
}
.login a:hover {
  color: #fe5b1f;
  text-decoration: none;
}
.container {
  width: 100% !important;
}
li.insurance {
  padding-top: 30px !important;
}
li.our-story {
  padding-top: 30px !important;
}
li.login-signup {
  padding-top: 30px !important;
}
li.get-covered {
  margin-top: 15px;
  padding-bottom: 10px !important;
  padding-top: 10px !important;
}
li.our-story {
  margin-right: 200px !important;
  font-family: AvantGarde;
  letter-spacing: .30em;
  color: white;
}
li.login-signup {
  font-style: italic;
  font-size: 12px;
  font-family: Adelle PE;
  letter-spacing: .30em;
  color: white;
}
li.get-covered {
  border-color: #EF7440;
  border-style: solid;
  color: white;
  letter-spacing: .30em;
  font-family: Adelle PE;
}
li.get-covered:hover {
  background-color: #EF7440;
}
li.insurance {
  margin-right: 80px;
  margin-left: 80px;
  color: white;
  font-family: AvantGarde;
  letter-spacing: .30em;
}

<div class="header"> <img class="header-background" src="https://s30.postimg.org/3q4ox3s81/background-image-chrisdavenport.png">
  <div class="orange-bar">
      <img class="orange-bar-image" src="https://s9.postimg.org/sdrolfjan/orange-bar.png">
  </div>
  <div class="topnav">
    <nav>
      <ul>
        <li class="home"><img src="https://s2.postimg.org/nhr4xxqcp/northman_wordmark_CMYK.png">
        </li>
        <li class="dropdown">
            <a href="#"><b>INSURANCE</b> <i class="fa fa-angle-down" aria-hidden="true"></i></a>
            <ul class="dropdown-content">
                <li><a href="#"><i>INDIVIDUAL</i></a>
                </li>
                <li><a href="#"><i>CORPORATE</i></a>
                </li>
            </ul>
        </li>
        <li class="our-story">OUR STORY</li>
        <li class="login-signup">Log In | Sign up</li>
        <li class="get-covered">GET <strong style="font-style:italic">COVERED</strong>
        </li>
      </ul>
    </nav>
  </div>
  <h1 class="text-inside-orange">INSURANCE FOR THE WILD</h1>
</div>
&#13;
&#13;
&#13;

有什么想法我做错了吗?此外,我想将菜单标题中的所有内容排成一行,我的下拉列表应该从该橙色线的边框开始。

1 个答案:

答案 0 :(得分:0)

您使用导航div中隐藏的溢出导致了问题。这是jsfiddle

.topnav {
    position: relative;
    top: -890px;
    background-color: rgba(0, 0, 0, 0.5);
    height: 89px;
    border-bottom: 3px solid #EF7440;
    /*overflow: hidden;*/
}