bootstrap中下拉菜单中如果有很多项的话怎么让下拉菜单出现滚动条而不是整个页面出现滚动条?

133088515 发布于 2015/03/14 16:53
阅读 4K+
收藏 0

如果,怎么让下拉列表出现滚动框而不是页面滚动呢?

代码如下:

<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
 <link href="css/index.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
  <div class="container">
    <div class="row">
   <div class="col-xs-4">
  <div class="dropdown text-center">
    <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true" style="border:none;">
   类别
   <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别1</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别2</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别3</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别4</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别1</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别2</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别3</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别4</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别1</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别2</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别3</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别4</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别1</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别2</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别3</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别4</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别1</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别2</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别3</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别4</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别1</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别2</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别3</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别4</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别1</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别2</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别3</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别4</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别1</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别2</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别3</a></li>
   <li role="presentation"><a role="menuitem" tabindex="-1" href="#">类别4</a></li>
    </ul>
  </div>
   </div>
 </div>
<!------------------------------------------------->


 <div class="row">
  <div class="col-xs-12">
   <button type="button" class="btn btn-default" style="width:100%;border:none;">加载更多...</button>
  </div>
 </div>
  </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

 

加载中
0
xialeistudio
xialeistudio
<ul style="height:100px;overflow:scroll">
<li>dsadsa</li>
<li>dsadsa</li>
<li>dsadsa</li>
<li>dsadsa</li>
<li>dsadsa</li>
<li>dsadsa</li>
</ul>



xialeistudio
xialeistudio
回复 @133088515 : 恩,全栈工程师为您服务~,哈哈
1
133088515
谢啦,刚才已经解决啦,跟你回答的解决方法一样~!
0
Vity
Vity
max-height
泽东我是少奇
泽东我是少奇
但是手机上面貌似不支持
Vity
Vity
@133088515 java的,非前端,据经验,加最大高度,设置滚动条是否显示, 放到div里面
1
133088515
是在UL 里面加上max-height=“数字” 么?还是在样式里面加呢?试了一下并没有效果
返回顶部
顶部