Bootstrap-Multiselect:如果使用overflow-y,Dropdown是underneatch外部容器

时间:2018-03-19 17:27:54

标签: jquery html css twitter-bootstrap bootstrap-multiselect

我正在使用Bootstrap-Multiselect(link)...当外部容器有溢出-y:scroll和max-height ...时,multiselect的下拉列表消失。如何让它显示在过滤器容器上?

HTML:

<div class="container filter-container">    

 <div class="row">
  <div class="col-md-12 search-box">          
      <div class="col-md-12">
        <form role="form-inline">
          <div class="form-group search-form-group">
            <label class="search-label">Users:</label>
            <div class="mid-width">
              <select class="select-users form-control"></select>
            </div>
          </div>
        </form>    
      </div>                                                                                        
  </div>  
 </div>  

</div>  

CSS:

.filter-container {
    padding: 1%;
    border: 1px solid #eee;
    max-height: 100px;
    overflow-y: scroll;
    background-color: #f8f8f8;
}

JS:

$(document).ready(function() {
  $('.select-users').multiselect({
        maxHeight: 400,
        buttonWidth: '100%' 
    });
    var accounts = [
        { label: 'UserID 1', value: '1' },
        { label: 'UserID 2', value: '2' },      
        { label: 'UserID 3', value: '3' }, 
        { label: 'UserID 4', value: '4' },         
        { label: 'All', value: '' }  
        ];  

    $('.select-users').multiselect('dataprovider', accounts);  
});

Fiddle

我认为此https://github.com/davidstutz/bootstrap-multiselect/issues/382也解决了这个问题。

2 个答案:

答案 0 :(得分:0)

在你的css中添加一个类

.multiselect-container {
  position:relative;
}

Fiddle

答案 1 :(得分:0)

试试这个

<select class="selectpicker" multiple>
  <option>Mustard</option>
  <option>Ketchup</option>
  <option>Relish</option>
</select>

在示例中 click