bootstrap模态框居中

旧城等待, 2022-08-10 09:28 372阅读 0赞

API网址:http://www.runoob.com/bootstrap/bootstrap-button-plugin.html
http://v3.bootcss.com/css/

实现模态框居中:

  1. function centerModals() {
  2. $('.modal').each(
  3. function(i) {
  4. var $clone = $(this).clone().css('display', 'block')
  5. .appendTo('body');
  6. var top = Math.round(($clone.height() - $clone.find(
  7. '.modal-content').height()) / 2);
  8. top = top > 0 ? top : 0;
  9. $clone.remove();
  10. $(this).find('.modal-content').css("margin-top", top);
  11. });
  12. }
  13. $('.modal').on('show.bs.modal', centerModals);
  14. $(window).on('resize', centerModals);

发表评论

表情:
评论列表 (有 0 条评论,372人围观)

还没有评论,来说两句吧...

相关阅读

    相关 bootstrap实例

    模态框(Modal)是覆盖在父窗体上的子窗体。通常,目的是显示来自一个单独的源的内容,可以在不离开父窗体的情况下有一些互动。子窗体可提供信息、交互等。 实例: 在这里我...