问答详情
源自:3-10 弹出框制作

怎样让模态框居中呢?现在只能设置居上居下,但不能垂直居中,可以做到垂直居中吗???

提问者:蚊子漫布 2014-10-31 16:40

个回答

  • purple_yao
    2014-10-31 18:40:06
    已采纳

    可以在bootstrap.js文件900行后面添加如下代码,便可以实现垂直居中。

    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";
              }
          });