twitter-bootstrap - 无法在 Bootstrap 3 中添加 Y 滚动条以折叠元素

标签 twitter-bootstrap css twitter-bootstrap-3

能否请您看一下这个演示,让我知道为什么我无法将 Y 滚动条添加到 Bootstrap 中 collapse in 元素内的 .well 中3?

@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.well{
      height: 120px !important;
      max-height: 120px !important;
      overflow-y: visible;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
  <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
  Show Scroolbar
</a>
<br />
<br />  
<div class="collapse" id="collapseExample">
  <div class="well">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  </div>
</div>
  
</div>

谢谢

最佳答案

只需更改 overflow-y 属性并删除 height 属性。

@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.well{
      max-height: 120px !important;
      overflow-y: auto;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
  <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
  Show Scroolbar
</a>
<br />
<br />  
<div class="collapse" id="collapseExample">
  <div class="well">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  </div>
</div>
  
</div>

关于twitter-bootstrap - 无法在 Bootstrap 3 中添加 Y 滚动条以折叠元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39156955/

相关文章:

html - 使导航全高

html - flexbox 内的自动换行不起作用

jquery - 内容在立方体下方移动

html - 使列与具有嵌套框的列相同的高度

html - 如何在移动设备上将 div 移动到另一行?

html - 减少 Bootstrap 的列间距

html - 如何使用 Twitter BootStrap 实现下拉式可点击图标菜单?

html - CSS/LESS更改多选中所选选项的背景颜色

javascript - Bootstrap 导航栏事件状态

html - Bootstrap 3 Accordion 对 Table 的影响很慢