2017-08-17 132 views
1

我不知道這是爲什麼不工作?我試圖做一個下拉菜單,當我在頁盤旋在它的工作,但如果我在臨客徘徊它不到風度工作總之,這個下拉列表則相反 我需要修復或更好的辦法這個下拉菜單JS下拉菜單不工作

enter image description here

enter image description here

的Html

<body> 
    <div class="wrap"> 
     <nav class="navbar navbar-default navbar-fixed-top navbarcolor "> 
      <div class="container "> 
       <div class="navbar-header active"> 
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> 
         <span class="sr-only">Toggle navigation</span> 
         <span class="icon-bar"></span> 
         <span class="icon-bar"></span> 
         <span class="icon-bar"></span> 
        </button> 
        <a class="navbar-brand Brand-Color active " href="#">MediQ.ch</a> 
       </div> 
       <div id="navbar" class="navbar-collapse collapse"> 

        <ul class="nav navbar-nav navbar-right"> 
         <li><a class="navbar-R-C " href="#">AdminStraion</a> 
         </li> 

         <li class="dropdown sub-menu-parent"> 
          <a id="drop" href="#" class="navbar-R-C nav-link dropdown-toggle " data-toggle="dropdown" aria-expanded="false">BookMarker 
        <span class="caret"></span></a> 

          <ul id="content" class="dropdown-menu " role="menu"> 
           <li><a class="content " href="#">ACETILXSUBSTANCE2</a> 
           </li> 
           <li><a class="content " href="#">HIDROCORTIZOLXBENZTIL</a> 
           </li> 
           <li><a class="content " href="#">SUBSTANCE3XSUBSTANCE4</a> 
           </li> 

          </ul> 
         </li> 

         <li><a class="navbar-R-C " href="#">Contact</a> 
         </li> 
        </ul> 

       </div> 
       <!--/.nav-collapse --> 
      </div> 
     </nav> 
    </div> 



</body> 

的CSS

.navbar-R-C:hover { 
    color: white !important; 
} 
.content { 
    color: White !important; 
} 
.dropdown-menu { 
    min-width: 250px; 
    max-width: 250px; 
    text-align: center; 
    background-color: #3E606F; 
    margin-top: -6px !important; 
    color: white !important; 
    border-radius: 15px !important; 
} 
.dropdown-menu > li > a:hover { 
    text-align: center; 
    background-color: #EC407A; 
    font-weight: bold; 
    margin-left: 7px !important; 
    margin-right: 7px !important; 
    display: inline-block; 
    color: White; 
    border-radius: 10px !important; 
} 
.dropdown-menu:after { 
    position: absolute; 
    margin-left: 210px; 
    top: -6px; 
    left: -30px; 
    border-right: 10px solid transparent; 
    border-bottom: 10px solid #3E606F; 
    border-left: 10px solid transparent; 
    content: ''; 
} 
.dropdown:hover .dropdown-menu { 
    display: block; 
} 

JS

$(document).ready(function() { 
    $('.wrap nav ul li').hover(function() { 
     // Toggles slide but stops if not hover anymore 
     $(this).find('ul').stop().slideToggle(); 
     // Toggles on and of the active class (triangle) 
     $(this).find('div').toggleClass('active'); 
    } 
    ); 
} 
); 

回答

0

使用此。它包含了你的代碼,但一些CSS是通過引導CSS所以你必須重寫引導CSS看起來像你想要的覆蓋。而新的事情是bootstrap.css,bootstrap.js和的jquery.js不要忘記這裏包含這些文件直接從網上可以下載和鏈接,這些文件以供離線使用它加載。

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
    <title>Bootstrap Example</title> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
</head> 
<body> 

    <nav class="navbar navbar-default navbar-fixed-top navbarcolor "> 
     <div class="container "> 
      <div class="navbar-header active"> 
       <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> 
        <span class="sr-only">Toggle navigation</span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
       </button> 
       <a class="navbar-brand Brand-Color active " href="#">MediQ.ch</a> 
      </div> 
      <div id="navbar" class="navbar-collapse collapse"> 

       <ul class="nav navbar-nav navbar-right"> 
        <li><a class="navbar-R-C " href="#">AdminStraion</a> 
        </li> 

        <li class="dropdown sub-menu-parent"> 
         <a id="drop" href="#" class="navbar-R-C nav-link dropdown-toggle " data-toggle="dropdown" aria-expanded="false">BookMarker 
       <span class="caret"></span></a> 

         <ul id="content" class="dropdown-menu " role="menu"> 
          <li><a class="content " href="#">ACETILXSUBSTANCE2</a> 
          </li> 
          <li><a class="content " href="#">HIDROCORTIZOLXBENZTIL</a> 
          </li> 
          <li><a class="content " href="#">SUBSTANCE3XSUBSTANCE4</a> 
          </li> 

         </ul> 
        </li> 

        <li><a class="navbar-R-C " href="#">Contact</a> 
        </li> 
       </ul> 

      </div> 
      <!--/.nav-collapse --> 
     </div> 
    </nav> 
    <div class="container"> 
     <h3>Navbar With Dropdown</h3> 
     <p>This example adds a dropdown menu for the "Page 1" button in the navigation bar.</p> 
    </div> 

    </body> 
</html> 
+0

你可以給我的例子爲bootstrab droopdown但懸停效果PLZ –

+0

你想要徘徊,你能解釋一下,這樣我可以幫助和正是你想要徘徊 –

+0

我需要財產以後這樣的時候做什麼https://codepen.io/gjermundnor/pen/KwpRbV?q=jquery%20drop%20down%20menu&limit=all&order=popularity&depth=everything&show_forks=false –