答案 0 :(得分:27)
模态不允许任何溢出,您可以使用以下方法修复它:
.modal { overflow: visible; }
.modal-body { overflow-y: visible; }
如果此修复程序产生错误,您可能需要添加一个类以仅将这些规则应用于真正需要它的模式。
答案 1 :(得分:3)
如果无法删除溢出:auto 你可以做这样的事情
$('.drop-down-inside-modal').on('click' , '.dropdown-toggle', function(event){
var self = $(this);
var selfHeight = $(this).parent().height();
var selfWidth = $(this).parent().width();
var selfOffset = $(self).offset();
var selfOffsetRigth = $(document).width() - selfOffset.left - selfWidth;
var dropDown = self.parent().find('ul');
$(dropDown).css({position:'fixed', top: selfOffset.top + selfHeight , left: 'auto', right: selfOffsetRigth , width: '160px'});
});
function fixDropdownPosition(){
var openDropdownButton = $('.drop-down-inside-modal.open');
if($(openDropdownButton).length){
var selfHeight = $(openDropdownButton).height();
var selfWidth = $(openDropdownButton).width();
var openDropdownButtonOffset = $(openDropdownButton).offset();
var openDropdownButtonOffsetRigth = $(document).width() - openDropdownButtonOffset.left - selfWidth;
var openDropdown = $(openDropdownButton).find('ul');
$(openDropdown).css({position:'fixed', top: openDropdownButtonOffset.top + selfHeight , left: 'auto' , right: openDropdownButtonOffsetRigth, width: '160px'});
};
};
$(".modal-body").unbind("scroll");
$(".modal-body").scroll(function(){
fixDropdownPosition();
});
$( window ).resize(function() {
fixDropdownPosition();
});