2015-10-16 148 views
0

我正在製作一個網站,當我嘗試將其定位到頁面中間時,導航欄的下拉菜單與父導航欄不匹配。當我使用相對定位時,它不排隊。這是我的代碼:導航欄定位

nav ul ul { 
 
    display: none; 
 
    margin: 0; 
 
    padding: 10px; 
 
    list-style-type: none; 
 
    text-align: center; 
 
    background-color: #A7C5A5; 
 
} 
 
nav ul li:hover > ul { 
 
    display: block; 
 
} 
 
nav ul { 
 
    text-decoration: none; 
 
    padding: 0em; 
 
    color: #030; 
 
    background-color: #A7C5A5; 
 
    font-family: Georgia, "Times New Roman", Times, serif; 
 
    list-style: none; 
 
    position: relative; 
 
    display: inline-table; 
 
    top: 60px; 
 
    left: 300px; 
 
    float: inherit; 
 
} 
 
nav ul:after { 
 
    content: ""; 
 
    clear: both; 
 
    display: block; 
 
} 
 
nav ul li { 
 
    float: left; 
 
    display: inline; 
 
} 
 
nav ul li:hover { 
 
    background: #4b545f; 
 
} 
 
nav ul li:hover a { 
 
    color: #000; 
 
    background-color: #CCC; 
 
} 
 
nav ul li a { 
 
    display: block; 
 
    padding: 25px 40px; 
 
    color: #757575; 
 
    text-decoration: none; 
 
} 
 
nav ul ul { 
 
    background-color: #A7C5A5; 
 
    border-radius: 0px; 
 
    padding: 0; 
 
    position: relative; 
 
    top: 60px; 
 
    left: 300px; 
 
} 
 
nav ul ul li { 
 
    float: none; 
 
    border-top: 1px solid #6b727c; 
 
    border-bottom: 1px solid #575f6a; 
 
    position: relative; 
 
} 
 
nav ul ul li a { 
 
    padding: 15px 40px; 
 
    color: #fff; 
 
} 
 
nav ul ul li a:hover { 
 
    color: #000; 
 
    background-color: #CCC; 
 
}
<body> 
 
    <div id="bg-right"></div> 
 
    <div id="bg-left"></div> 
 
    <div class="img"> 
 
    <img src="greenlogo.jpg" width="504" height="160"> 
 
    </div> 
 
    <nav> 
 
    <ul> 
 
     <li><a href="#"> Home</a></li> 
 
     <li><a href="#">Animals</a> 
 
     <ul> 
 
      <li><a href="#">Disney</a></li> 
 
      <li><a href="#">Farm</a></li> 
 
      <li><a href="#">Nickolodean</a> 
 
     </ul> 
 
     </li> 
 
     <li><a href="#">About</a></li> 
 
     <li><a href="#">Contact</a></li> 
 
    </ul> 
 
    </nav> 
 
</body>

回答

0

我試圖讓一個小提琴私人和我在Chrome-Devconsole看到,有些款式是雙使用或用於在那裏你會不會,他們正在使用。我會建議使用不同的UL的類

Devlen