| 
 | 
 
| 
   
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
Bootstrap3弹出模态框(modal)居中的控制 
 
在页面中添加以下js即可:-     //模态框居中的控制
 
 -     _centerModals=function(){
 
 -         $('.modal').each(function(i){   //遍历每一个模态框
 
 -             var $clone = $(this).clone().css('display', 'block').appendTo('body');    
 
 -             var top = Math.round(($clone.height() - $clone.find('.modal-content').height()) / 2);
 
 -             top = top > 0 ? top : 0;
 
 -             $clone.remove();
 
 -             $(this).find('.modal-content').css("margin-top", top-30);  //修正原先已经有的30个像素
 
 -         });
 
 -     }
 
 -     $('.modal').on('show.bs.modal', _centerModals);      //当模态框出现的时候
 
 -     $(window).on('resize', _centerModals); 
 
  复制代码 |   
 
 
 
 |