解决bootstrap模态框居中问题


完美解决办法:

  在bootstrap.js或bootstrap.min.js文件中找到Modal.prototype.show方法。

  在that.$element.addClass('in').attr('aria-hidden', false)代码前加入下面这段代码。

 

 that.$element.children().eq(0).css("position", "absolute").css({
          "margin": "0px",
          "top": function () {
              return (that.$element.height() - that.$element.children().eq(0).height() - 40) / 2 + "px";
          },
          "left": function () {
              return (that.$element.width() - that.$element.children().eq(0).width()) / 2 + "px";
          }
      });

 

运行结果;

 

 

 

 亲测有效,特此记录。而且此方法也能解决bootbox无法居中的问题。

 

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM