Boostrap 模态框 水平垂直居中问题

        var editorB = new UE.ui.Editor({ initialFrameHeight: 350, initialFrameWidth: 600 });
        editorA.render("ScienceContentA");
        editorB.render("ScienceContentB");
        $(function () {
            //$("#AddUpdateModalA").modal("hide").css({
            //    //top: 0,
            //    left:0,
            //    "margin-top": function () {
            //        //return -$(window).height()/2 + ($(window).height() - $(this).height()) / 2;
            //        return - ($(this).height() / 2)-70;
            //    },
            //    "margin-left": function () {
            //        return ($(window).width() - $(this).width())/2;
            //    }
            //});
            $('.modal').on('show.bs.modal', centerModals);
            $(window).on('resize', centerModals);
            //PageQuery();//分页查询数据
        });
        //模态框水平垂直居中函数
        function centerModals() {
            $('.modal').each(function (i) {
                var top = -($(this).height() / 2) - 70;
                var left = ( $ (window).width() - $(this).width()) / 2;
                $(this).css("margin-top", top);
                $(this).css("margin-left", left);
            });
        }
原文地址:https://www.cnblogs.com/whaozl/p/4536458.html