2014-05-23 171 views
0

我已經創建了一個菜單欄,沒有bootstrap問題是,下拉菜單中的Z-index在下拉菜單中不起作用,下面有一個圖像時我給出了相對位置和絕對位置的圖像和菜單,任何人都可以幫忙嗎?Css下拉菜單z-index問題

代碼:

<ul id="nav"> 
    <li class="current"><a href="#">Home</a></li> 
    <li><a class="nolink">MASTER</a> 
     <ul> 
      <li><a href="master_textile.php">TEXTILE</a></li> 
      <li><a href="master_nontextile.php">NON-TEXTILE</a></li> 
      <li><a href="branch_name_master.php">BRANCH NAME</a></li> 
      <li><a href="initial_stock.php">INITIAL STOCK - TEXTILE</a></li> 
      <li><a href="initial_stock_non_textile.php">INITIAL STOCK - NON TEXTILE</a></li> 
     <li><a href="initial_stock_silk.php">INITIAL STOCK - SILK</a></li> 
      <li><a href="customer_details_master.php">CUSTOMER DETAILS</a></li> 
      <li><a href="percent.php">PERCENT</a></li> 
     </ul> 
    </li> 
    <li><a class="nolink">PURCHASE</a> 
     <ul> 
      <li><a href="purchase_textile.php">TEXTILE</a></li> 
      <li><a href="purchase_silk_textile.php">SILK</a></li> 
      <li><a href="purchase_nontextile.php">NON-TEXTILE</a></li> 
     </ul> 
    </li> 
    <li><a class="nolink">RETAIL SALE</a> 
     <ul> 
     <li><a href="retail_sales.php">TEXTILE</a></li> 
      <li><a href="retail_sales_silk.php">SILK</a></li> 
      <li><a href="retailsale_nontextile.php">NON-TEXTILE</a></li> 
     </ul> 
    </li> 
    <li><a class="nolink">WHOLE SALE</a> 
     <ul> 
      <li><a href="whole_sales.php">TEXTILE</a></li> 
      <li><a href="whole_sales_silk.php">SILK</a></li> 
      <li><a href="whole_nontextile.php">NON-TEXTILE</a></li> 
     </ul> 
    </li> 
    <li><a class="nolink">RETURN BILLS</a> 
     <ul> 
      <li><a href="retail_textile_cancel_bill.php">RETURN BILL - TEXTILE</a></li> 
      <li><a href="silk_return_bill.php">RETURN BILL - SILK</a></li> 
     </ul> 
    </li> 
    <li><a class="nolink">SUMMARY</a> 
     <ul> 
     <li><a class="nolink">BILL SUMMARY</a> 
      <ul> 
       <li><a href="Summary_textile.php">RS - TEXTILE</a></li> 
       <li><a href="summary_nontextile.php">RS - NON-TEXTILE</a></li> 
       <li><a href="wholesale_summary_textile.php">WS - TEXTILE</a></li> 
       <li><a href="wholesale_summary_nontextile.php">WS - NON-TEXTILE</a></li> 
       <li><a href="purchase_summary_textile.php">PU - TEXTILE</a></li> 
       <li><a href="purchase_summary_nontextile.php">PU - NON-TEXTILE</a></li> 
      </ul> 
      </li> 
      <li><a class="nolink">STOCK BOOK</a> 
       <ul> 
        <li><a href="stockbook.php">TEXTILE</a></li> 
        <li><a href="stockbook_silk.php">SILK</a></li> 
        <li><a href="stockbook_nontextile.php">NON-TEXTILE</a></li> 
       </ul> 
      </li> 
      <li><a class="nolink">ALTER</a> 
       <ul> 
        <li><a href="paisa_alter.php">PAISA - ALTER</a></li> 
        <li><a href="summary_date_alter.php">DATE - ALTER</a></li> 
       </ul> 
      </li> 
     </ul> 
    </li> 
    <li><a class="nolink">LOAN</a> 
     <ul> 
      <li class="dropdown_submenu non"><a href="#">TEXTILE</a> 
       <ul> 
        <li><a href="loanlist.php">VIEW LOAN LIST</a></li> 
        <li><a href="loan_personal_list.php">PERSONAL LIST</a></li> 
        <li><a href="loancr.php">LOAN CR</a></li> 
       </ul> 
      </li> 
      <li><a href="">NON-TEXTILE</a> 
       <ul> 
        <li><a href="loan_list_nontex.php">PERSONAL LIST</a></li> 
        <li><a href="loan_cr_nontex.php">LOAN CR</a></li> 
       </ul> 
      </li> 
     </ul> 
    </li> 
    <li><a class="nolink">REPORT</a> 
     <ul> 
      <li><a href="#">TEXTILE</a> 
       <ul> 
        <li><a href="initial_tex_report.php">INITIAL</a></li> 
        <li><a href="closing_tex_report.php">CLOSING</a></li> 
       </ul> 
      </li> 
      <li><a href="#">NON-TEXTILE</a> 
      <ul> 
       <li><a href="initial_nontex_report.php">INITIAL</a></li> 
       <li><a href="closing_nontex_report.php">CLOSING</a></li> 
      </ul> 
      </li> 
     </ul> 
    </li> 
</ul> 

CSS:

a { 
    color: #3bb3a9; 
} 
#nav { 
    padding: 2px 4px 0; 
    line-height: 100%; 
    background:#3bb3a9; /* for non-css3 browsers */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#3bb3a9', endColorstr='#3bb3a9'); /* for IE */ 
    background: -webkit-gradient(linear, left top, left bottom, from(#3bb3a9), to(#3bb3a9)); /* for webkit browsers */ 
    background: -moz-linear-gradient(top, #3bb3a9, #3bb3a9); /* for firefox 3.6+ */ 

    border: solid 1px #329c92; 
} 
#nav li { 
    margin: 0 10px; 
    padding: 0 0 5px; 
    float: left; 
    position: relative; 
    list-style: none; 
} 
/* main level link */ 
#nav a { 
    font-weight: bold; 
    color: white; 
    text-decoration: none; 
    display: block; 
    padding: 4px 10px; 
    margin: 0; 
    -webkit-border-radius: 1.6em; 
    -moz-border-radius: 1.6em; 
} 
/* main level link hover */ 
#nav .current > a, #nav li:hover > a { 
    background:#329c92; /* for non-css3 browsers */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#329c92', endColorstr='#329c92'); /* for IE */ 
    background: -webkit-gradient(linear, left top, left bottom, from(#329c92), to(#329c92)); /* for webkit browsers */ 
    background: -moz-linear-gradient(top,#329c92, #329c92); /* for firefox 3.6+ */ 

    color: white; 
} 
/* sub levels link hover */ 
#nav ul li:hover a, #nav li:hover li a { 
    background: none; 
    border: none; 
    color: white; 
    -webkit-box-shadow: none; 
    -moz-box-shadow: none; 
    cursor:pointer; 
} 
#nav ul a:hover { 
    background: #329c92 !important; /* for non-css3 browsers */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#329c92', endColorstr='#329c92'); /* for IE */ 
    background: -webkit-gradient(linear, left top, right bottom, from(#329c92), to(#329c92)) !important; /* for webkit browsers */ 
    background: -moz-linear-gradient(top, #329c92, #329c92) !important; /* for firefox 3.6+ */ 

    color: white !important; 
    -webkit-border-radius: 0; 
    -moz-border-radius: 0; 
} 
/* level 2 list */ 
#nav ul { 
    background: #3bb3a9; /* for non-css3 browsers */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#3bb3a9', endColorstr='#3bb3a9'); /* for IE */ 
    background: -webkit-gradient(linear, left top, left bottom, from(#3bb3a9), to(#3bb3a9)); /* for webkit browsers */ 
    background: -moz-linear-gradient(top, #3bb3a9, #3bb3a9); /* for firefox 3.6+ */ 

    display: none; 
    margin: 0; 
    padding: 0; 
    width: 185px; 
    position: absolute; 
    top: 27px; 
    left: 0; 
    border: solid 1px #3bb3a9; 
    -webkit-border-radius: 2px; 
    -moz-border-radius: 2px; 
    border-radius: 2px; 
} 
/* dropdown */ 
#nav li:hover > ul { 
    display: block; 
} 
#nav li ul.stayopen { 
    display: block !important; 
} 
#nav li ul.stayopen li a { 
    color: white; 
} 
#nav ul li { 
    float: none; 
    margin: 0; 
    padding: 0; 
} 
#nav ul a { 
    font-weight: normal; 
} 
/* level 3+ list */ 
#nav ul ul { 
    left: 181px; 
    top: -3px; 
} 
/* rounded corners for first and last child */ 
#nav ul li:first-child > a { 
    -webkit-border-top-left-radius: 9px; 
    -moz-border-radius-topleft: 9px; 

    -webkit-border-top-right-radius: 9px; 
    -moz-border-radius-topright: 9px; 
} 
#nav ul li:last-child > a { 
    -webkit-border-bottom-left-radius: 9px; 
    -moz-border-radius-bottomleft: 9px; 
    -webkit-border-bottom-right-radius: 9px; 
    -moz-border-radius-bottomright: 9px; 
} 
/* clearfix */ 
#nav:after { 
    content: "."; 
    display: block; 
    clear: both; 
    visibility: hidden; 
    line-height: 0; 
    height: 0; 
} 
#nav { 
} 
html[xmlns] #nav { 
    display: block; 
} 
* html #nav { 
    height: 1%; 
} 

enter image description here

+1

請嘗試添加位置:relative; z-index:9999;在#nav –

+0

我曾嘗試不工作。 – user3593694

+0

我已經等待了。答案我會發布它 – user3593694

回答

1

爲下一級導航添加zindex,如下所示。

#nav ul 
{ 
z-index:999 !important; 
} 
0

我發現答案太過其現在的工作...

#nav li { 
    margin: 0 10px; 
    padding: 0 0 5px; 
    float: left; 
    position: relative; 
    list-style: none; 
    z-index:1; 
} 

通過在CSS中添加此代碼。