我为下拉列表元素创建了滚动条。我应该从下拉列表中的第二个元素开始滚动条。
如何实现?
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2 class="bold">Scrollable Menu</h2>
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Scrollable Menu <span class="caret"></span></button>
<ul class="dropdown-menu scrollable-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
</ul>
</div>
</div>
</div>
</div>
.scrollable-menu {
height: auto;
max-height: 200px;
overflow-x: hidden;
}
答案 0 :(得分:0)
估计或计算直到第二个元素的高度。然后将其替换为设置为auto;
的高度,然后移除max-height: 200px;
.scrollable-menu {
height: estimated height;
overflow-x: scroll;
}