select2在bootstrap的modal中下拉打不开问题

Bootstrap中的Modal,select2插件会有不显示,因为其z-index小于modal

.select2-container--open{

        z-index:9999999         

}

或者 修正z-index之后,select2不会自动失去焦点的问题

   /*select2在Bootstrap的modal中默认被遮盖,现在强制显示在最前*/
    .select2-drop {
        z-index: 10050 !important;
    }
 
    .select2-search-choice-close {
        margin-top: 0 !important;
        right: 2px !important;
        min-height: 10px;
    }
 
        .select2-search-choice-close:before {
            color: black !important;
        }
    /*防止select2不会自动失去焦点*/
    .select2-container {
        z-index: 16000 !important;
    }
 
    .select2-drop-mask {
        z-index: 15990 !important;
    }
 
    .select2-drop-active {
        z-index: 15995 !important;
    }

// 可不填
$(function(){
    $("#PaymentId").select2({
        placeholder: "--请选择--",
        dropdownParent: $("#myModal"),
        allowClear: true
    });

});



猜你喜欢

转载自blog.csdn.net/weixin_39509262/article/details/79761131
今日推荐