Bootstrap对话框改变其默认宽高,高度不会自适应居中。为解决这个问题,最好的方式是能够通过css来解决,试了几种网上的方案发现都不行。然后想到可以通过js来修正,什么时候修正最好?于是想到可以注册全局的事件。

  下表是Bootstrap官方的事件。

Event Type Description
show.bs.popover This event fires immediately when the show instance method is called.
shown.bs.popover This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete).
hide.bs.popover This event is fired immediately when the hide instance method has been called.
hidden.bs.popover This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete).
inserted.bs.popover This event is fired after the show.bs.popover event when the popover template has been added to the DOM.
Copy
$('#myPopover').on('hidden.bs.popover', function () {
// do something…
})   但是,我使用的是$(aa).modal('show'),所以改成这样:
  
$(function () {
//修正modal弹窗高度不能自适应的问题
$('body .modal').on('show.bs.modal', function () {
var $cur = $(this);
$cur.css("top", ($(window).height() - $cur.height()) / 2);
});
});

  

 

Bootstrap模态框垂直高度居中问题的更多相关文章

  1. bootstrap模态框垂直居中

    很久没有写东西了,之前想写一些移动端的东西以后补上吧,移动端发展还是蛮快的,回正题. 因为最近在弄一个系统,系统中引用了bootstrap,发现模态框垂直不居中,遂搜索了一下,也都试了一下,无非都是在 ...

  2. Bootstrap模态框modal的高度和宽度设置

    (1)高度 将style=“height:900px”放在<div class = "modal-dialog">或者更外层上,整个模态框的高度不会发生变化 如下图所示 ...

  3. JavaScript:bootstrap 模态框的简单应用

    最近用上了bootstrap这个强大的前端框架,有空来总结一下.这里记录下模态框的简单应用. 首先,要在页面中引入相应的js.css文件 <link href="css/bootstr ...

  4. js控制Bootstrap 模态框(Modal)插件

    js控制Bootstrap 模态框(Modal)插件 http://www.cnblogs.com/zzjeny/p/5564400.html

  5. Bootstrap模态框按钮

    1.触发模态框弹窗的代码 这里复制了一段Bootstrap模态框的代码 <h2>创建模态框(Modal)</h2> <!-- 按钮触发模态框 --> <but ...

  6. 解决bootstrap模态框内输入框无法获取焦点

    bootstrap 模态框中的input标签在某些情况下会无法获取焦点. 最终解决方法:去除模态框的 tabindex="-1" 属性即可

  7. Bootstrap 模态框(Modal)插件

    原文链接:http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html Bootstrap 模态框(Modal)插件 模态框(Modal)是覆 ...

  8. Bootstrap 模态框在用户点击背景空白处时会自动关闭

    问题: Bootstrap 模态框在用户点击背景空白处时,会自动关闭. 解决方法: 在HTML页面中编写模态框时,在div初始化时添加属性 aria-hidden=”true” data-backdr ...

  9. Bootstrap模态框(MVC)

    BZ这篇博客主要是为大家介绍一下MVC如何弹出模态框.本文如果有什么不对的地方,希望大神们多多指教,也希望和我一样的小菜多多学习.BZ在这里谢过各位. 首先要在页面加上一个点击事件: @Html.Ac ...

随机推荐

  1. jmeter笔记(4)--测试上传附件

    性能测试过程中有HTTP请求上传附件的场景,记录一下运用fiddler和jmeter实现jforum发表上传附件的帖子的过程. 1.fiddler录制脚本 2.打开录制的脚本,调整信息头管理器中信息 ...

  2. 简单记录一次getshell到进服务器的过程

    通过st2命令执行上次木马进行getshell 查看whoami,发现权限是administrator,直接net user xxx xxx123.. /add,发现拒绝访问 通过命令tasklist ...

  3. termux

    使用http服务,链接原服务器要挂vpn. apt edit-sources 如果提示 $ apt edit-sources e: Sub-process editor returned a n er ...

  4. Bellman-Ford&&SPFA

    我们前文说过,有关最短路径除了Floyed算法之外,还有许多更加好的方法.这里讲一下有关 Bellman-Ford和SPFA的知识 Bellman-Ford:复杂度O(VE) 有关Bellman-Fo ...

  5. Python菜鸟快乐游戏编程_pygame(2)

    Python菜鸟快乐游戏编程_pygame(博主录制,2K分辨率,超高清) https://study.163.com/course/courseMain.htm?courseId=100618802 ...

  6. ZooKeeper-API 监听

    以服务动态上下线通知为例 Client 监听服务器状态 public class DistributeClient { private String connectString = "127 ...

  7. HIS(LIS、PACS、RIS、EMR)系统简介

    HIS(LIS.PACS.RIS.EMR)系统简介 HIS:医院信息系统(Hospital Information System, HIS),利用电子计算机和通讯设备,为医院所属各部 门提供病人诊疗信 ...

  8. hadoop记录-Hadoop参数汇总

    Hadoop参数汇总 linux参数 以下参数最好优化一下: 文件描述符ulimit -n 用户最大进程 nproc (hbase需要 hbse book) 关闭swap分区 设置合理的预读取缓冲区 ...

  9. 各种类型文件的Content-Type

    各种类型文件的Content-Type 2017年11月27日 10:00:56 thebigdipperbdx 阅读数:7360   版权声明:本文为博主原创文章,未经博主允许不得转载. https ...

  10. text-stroke实现文字描边(镂空)、text-fill-color实现文字填充&渐变(+animation实现流光字体)

    text-stroke:<' text-stroke-width '> || <' text-stroke-color '>(text-stroke-width:设置或检索对象 ...