首页 > 其他 > 详细

解决bootstrap模态框居中问题

时间:2019-09-01 16:11:43      阅读:87      评论:0      收藏:0      [点我收藏+]

完美解决办法:

  在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无法居中的问题。

 

  

 

解决bootstrap模态框居中问题

原文:https://www.cnblogs.com/wutongvip/p/11442259.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!