解決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