2016-03-12 220 views
0

链接codepen溢出:滚动停止从激活

我想使它所以设置这个很长的列表中的最大高度(或高度),并为其余的滚动悬停状态。我能够轻松实现,与

身高:800px; 溢出:滚动;

这个问题我有是,“#subcategory”项目停止显示悬停当我申请溢出:滚动

任何想法是极大的赞赏!

基本HTML结构

<!-- Start Auto Transport --> 
    <li id="topCategory"><a href="#">Auto Transport</a> 
    <ul id="subContainer"> 
     <li id="subCategory"><a href="#">Auto Insurance</a></li> 
     <li id="subCategory"><a href="#">Auto Payment</a></li> 
     <li id="subCategory"><a href="#">Gas</a></li> 
     <li id="subCategory"><a href="#">Parking</a></li> 
     <li id="subCategory"><a href="#">Public Transportation</a></li> 
     <li id="subCategory"><a href="#">Service Parts</a></li> 
      <!-- add new becomes text field, user enters text then it becomes added as category --> 
      <li class="hideNewCategory"> 
      <a class="mmNewCat" data-number="1" href="#"><i class="icon ion-plus-circled"></i>Add New Category</a> 
      <input id="mmCat1" class="mmCatInpt" type="text" placeholder="Enter New Category" maxlength="25"></input> 
      </li> 
    </ul> 
    </li> 
    <!-- End Auto Transport --> 


    <!-- Start Bills Utilities --> 
    <li id="topCategory"><a href="#">Bills & Utilities</a> 
    <ul id="subContainer"> 
     <li id="subCategory"><a href="#">Domain Names</a></li> 
     <li id="subCategory"><a href="#">Fraud Protection</a></li> 
     <li id="subCategory"><a href="#">Home Phone</a></li> 
     <li id="subCategory"><a href="#">Hosting</a></li> 
     <li id="subCategory"><a href="#">Mobile Phone</a></li> 
     <li id="subCategory"><a href="#">Television</a></li> 
     <li id="subCategory"><a href="#">Utilities</a></li> 
     <!-- add new becomes text field, user enters text then it becomes added as category --> 
      <li class="hideNewCategory"> 
      <a class="mmNewCat" data-number="2" href="#"><i class="icon ion-plus-circled"></i>Add New Category</a> 
      <input id="mmCat2" class="mmCatInpt" type="text" placeholder="Enter New Category" maxlength="25"></input> 
      </li> 
    </ul> 
    </li> 
    <!-- End Bills Utilities --> 

有关CSS

ul li:hover #topContainer{ 
    display: block; 
} 

ul li a { 
    display: block; 
    color: $blue; 
    text-decoration: none; 
    font-family: verdana; 
    font-size: 14px; 
} 

#topContainer{ 
    list-style: none; 
    color: $blue; 
    width: 260px; 
    height: auto; 
    background: $white; 
    opacity: 0.9; 
    position: absolute; 
    z-index: 1000; 
    height:800px; 
    overflow:scroll; 
} 

#topCategory { 
    float: none; 
    width: auto; 
    height: 20px; 
    text-align: left; 
    margin-left: 15px; 
} 

#topCategory a:hover { 
    color: $white; 
    background-color: $blue; 
} 

#topCategory:hover #subContainer { 
    display: block; 
} 

#topCategory a { 
    font-size: 16px; 
    position: relative; 
    bottom: 41px; 
    margin-top: 46px; 
    margin-left: -15px; 
    padding: 20px 0 20px 20px; 
    border-bottom:1px solid $grey-10; 
} 

#topCategory a:hover { 
    color: $white; 
} 

#subContainer { 
    list-style: none; 
    color: $blue; 
    display: none; 
    font-size: 12px; 
    min-width: 230px; 
    width: 150px; 
    height: auto; 
    background: $white; 
    opacity: 0.9; 
    margin: -107px 0 0 245px; position: absolute; 
    z-index: 1000; 
    white-space:nowrap; 
} 

#subContainer a{ 
    border-bottom:1px solid $grey-10; 
    margin-top: 41px; 
} 

#subCategory { 
    float: none; 
    width: auto; 
    height: 20px; 
    text-align: left; 
    margin-left: 10px; 
} 

#subCategory:hover { 
    background: none; 
} 

.active { 
    background: $white; 
} 

#subCategory { 
    float: none; 
    // hover length 
    width:215px; 
    // hover length 
    text-align: left; 
    height: 25px; 
    margin-left: 15px; 
    margin-right: -43px; 
} 
+0

UPDATE:rofl the hover list items are there。你只需向右滚动看看他们:/完全忘了overflow-x和overflow-y,然而,我已经添加了overflow-y:scroll; overflow-x:visible!important;它仍然表现得像刚刚溢出一样:滚动 – kalmykov

回答

1

子目录应该是一个Class名称不是一个Id元素,改变这种事情会看起来更干净。

.subcategory { 

} 

<div class="subcategory"></div> 
+0

感谢您的回应。我改变了它,虽然在语义上我同意它不应该有重复ID的问题和行为仍然保持不变。任何其他想法? Codepen更新http://codepen.io/mkov88/pen/249908ec99bd8e7a787733ce5235b22a – kalmykov

+0

对不起,以前没有响应。看起来你已经解决了你的答案,谢谢分享。 – Graphicoding

+1

我没有解决问题,只是添加了关于它的信息。 – kalmykov