2015-10-09 53 views
1

在我的博客(http://www.khyberacademy.blogspot.com)中,下拉菜單不起作用。請指導我。下面給出了HTML代碼:&。下拉菜單不能在我的博客中工作

在懸停它不下降,也試圖改變顯示爲block & inline,但它並沒有解決我的問題。

HTML:

<!-- begin #topMenu --> 
<div class='clearfix' id='navigation-wrapper'> 
    <select id='responsive-main-nav-menu' onchange='javascript:window.location.replace(this.value);'><option selected='selected'>Menu</option></select> 
    <nav class='main-menu' id='main-navigation'> 
     <ul class='sf-menu' id='menu-top-menu'> 
      <li> 
       <a href='#' style='padding-right: 23px;'>Engineering<span class='downarrowclass'/></a> 
       <ul class='sub-menu' style='top: 127px; visibility: visible; left: 0px; width: 175px; display: none;'> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/Bridge%20Engineering'>Bridge Engineering</a></li> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/Pre-stressed%20Concrete'>Pre-stressed Concrete</a></li> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/CAD%2FCAM'>CAD/CAM</a></li> 
       </ul> 
      </li> 
      <li> 
       <a href='#' style='padding-right: 23px;'>COMMERCE<span class='downarrowclass'/></a> 
       <ul class='sub-menu' style='top: 127px; visibility: visible; display: none;'> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/AUDITING'>AUDITING</a></li> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/Business%20Communication'>BUSINESS COMMUNICATION</a></li> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/ECONOMICS'>ECONOMICS</a></li> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/STATISTICS'>STATISTIC</a></li> 
       </ul> 
      </li> 
      <li> 
       <a href='#' style='padding-right: 23px;'>COMPUTER<span class='downarrowclass'/></a> 
       <ul class='sub-menu' style='top: 127px; visibility: visible; display: none;'> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/Joomla%21'>JOOMLA</a></li> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/Windows%20Tricks'>WINDOWS TRICKS</a></li> 
        <li><a href='#'>WORDPRESS</a></li> 
        <li><a href='#'>BLOGGING</a></li> 
       </ul> 
      </li> 
      <li> 
       <a href='#' style='padding-right: 23px;'>GRAPHICS<span class='downarrowclass'/></a> 
       <ul class='sub-menu' style='top: 127px; visibility: visible; display: none;'> 
        <li><a href='http://khyberacademy.blogspot.com/search/label/CAD%2FCAM'>CAD/CAM</a></li> 
       </ul> 
      </li> 
      <li> 
       <a href='http://khyberacademy.blogspot.com/p/contact-us.html'>Contact</a> 
      </li> 
     </ul> 
    </nav> 
</div> 
<!-- end #topMenu --> 

CSS:

/* -------------------------------------------------- */ 
/* MAVIGATION 
/* -------------------------------------------------- */ 
.downarrowclass { 
    position: absolute; 
    top: 53px; 
    right: 5px; 
} 
.rightarrowclass { 
    position: absolute; 
    top: 10px; 
    right: 10px; 
} 
#main-navigation select { display: none } 
#main-navigation { float: right } 
#main-navigation > ul { margin: -30px 0 0 0px } 
#main-navigation ul li { 
    list-style: none; 
    float: left; 
    position: relative; 
} 
#main-navigation li a { 
    color: #898989; 
    font-family: 'Dosis', 'Verdana', sans-serif; 
    font-size: 16px; 
    font-weight: normal; 
    padding: 47px 12px 50px 12px; 
    margin: 0px 0px 10px 0; 
    position: relative; 
    text-align: center; 
    text-transform: uppercase; 
    float: left; 
    overflow: hidden; 
    line-height: 20px; 
} 
#main-navigation ul li a:hover, 
#main-navigation ul li.current-menu-ancestor > a, 
#main-navigation ul li.current-menu-item > a { 
    color: #9dcedf; 
    background: #f8f8f8; 
    border-bottom: 1pt solid #9dcedf; 
} 
#main-navigation ul ul li a { 
    display: block; 
    float: none; 
} 
#main-navigation ul ul { 
    background: url("http://1.bp.blogspot.com/-iIDMdP-Ub9I/UkEjY7k9a5I/AAAAAAAAJ-0/ZWPPe0dkcoA/s1600/menu-drop-bg.png") 20% 0% no-repeat; 
    padding-top: 8px; 
    display: none; 
    left: 0; 
    margin-top: -18px; 
    position: absolute; 
    width: 175px; 
    z-index: 99; 
    border-radius: 2px; 
    -moz-border-radius: 2px; 
    -webkit-border-radius: 2px; 
} 
#main-navigation ul ul ul { 
    background: url("http://1.bp.blogspot.com/-3LBiTw7Ht0U/UkEjYHu05eI/AAAAAAAAJ-k/pCHPYKrpKak/s1600/menu-drop-bg-2.png") 0% 50% no-repeat; 
    padding-left: 8px; 
    display: none; 
    left: 0; 
    position: absolute; 
    width: 175px; 
    z-index: 99; 
    border-radius: 2px; 
    -moz-border-radius: 2px; 
    -webkit-border-radius: 2px; 
} 
#main-navigation ul ul ul ul { 
    background: url("http://1.bp.blogspot.com/-3LBiTw7Ht0U/UkEjYHu05eI/AAAAAAAAJ-k/pCHPYKrpKak/s1600/menu-drop-bg-2.png") 0% 50% no-repeat; 
    padding-left: 8px; 
    display: none; 
    margin-left: 10px; 
    left: 0; 
    position: absolute; 
    width: 175px; 
    z-index: 99; 
    border-radius: 2px; 
    -moz-border-radius: 2px; 
    -webkit-border-radius: 2px; 
} 
#main-navigation ul ul li, 
#main-navigation ul ul li a { 
    padding: 0px 0 0 0px; 
    margin: 0px; 
    color: #FFF; 
    background: #615951; 
    font-family: "Arial", "Verdana"; 
} 
#main-navigation ul ul li { } 
#main-navigation ul ul li { float: none } 
#main-navigation ul li { 
    padding: 0; 
    margin: 0 0 0 20px; 
} 
#main-navigation ul ul a { 
    border: 0; 
    color: #fff; 
    display: block; 
    font-size: 11px; 
    font-weight: 400; 
    padding: 5px 10px !important; 
    text-align: left; 
    margin: 0; 
    text-transform: none; 
} 
#main-navigation ul ul a:hover, 
#main-navigation ul ul .hover > a, 
#main-navigation ul ul .current-menu-item > a, 
#main-navigation ul ul .current-menu-item > a:hover { 
    background: #9dcedf ; 
    color: #fff !important; 
    border: 0 !important; 
} 
#main-navigation ul li ul { 
    position: absolute; 
    left: 0px; 
    display: block; 
    visibility: hidden; 
    margin-left: 0px; 
    top: 0; 
} 
.downarrowclass, 
.rightarrowclass { 
    width:8px; 
    height:8px; 
    background:url(http://2.bp.blogspot.com/-bkf-TLVpTn4/UkEjaEMyKaI/AAAAAAAAJ_E/dyM2NDVqNNo/s1600/plus.png) top left no-repeat; 
    display:inline-block; 
    position: absolute; 
    right: 5px; 
    top: 53px 
} 
.rightarrowclass { 
    background-image:url(http://3.bp.blogspot.com/-ivF1y3GR6rw/UkEjZ8YMXlI/AAAAAAAAJ-8/xCB_X7XVIbw/s1600/plus-white.png); 
} 
+0

你可能需要使用Javascript或jQuery的。如果jQuery,onMouseOver顯示最接近的.sub菜單類,onMouseOut隱藏它 – deebs

回答

3

只需添加這個類,它會很好地工作。 希望這可以解決您的問題。

#main-navigation ul li:hover ul{display:block!important;} 
+0

感謝它的工作。 –

+0

您的歡迎:) 讓我知道你面對的任何其他問題,謝謝 – CreativePS

0

在每一個 「UL」 刪除display:none並設置visiblity:none。然後在下面添加Javascript代碼。

$("ul").hover(function(){ 
 
    $(this).css("visibility", "visibile"); 
 
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>