Bootstrap模态框垂直高度居中问题
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. |
$('#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模态框垂直高度居中问题的更多相关文章
- bootstrap模态框垂直居中
很久没有写东西了,之前想写一些移动端的东西以后补上吧,移动端发展还是蛮快的,回正题. 因为最近在弄一个系统,系统中引用了bootstrap,发现模态框垂直不居中,遂搜索了一下,也都试了一下,无非都是在 ...
- Bootstrap模态框modal的高度和宽度设置
(1)高度 将style=“height:900px”放在<div class = "modal-dialog">或者更外层上,整个模态框的高度不会发生变化 如下图所示 ...
- JavaScript:bootstrap 模态框的简单应用
最近用上了bootstrap这个强大的前端框架,有空来总结一下.这里记录下模态框的简单应用. 首先,要在页面中引入相应的js.css文件 <link href="css/bootstr ...
- js控制Bootstrap 模态框(Modal)插件
js控制Bootstrap 模态框(Modal)插件 http://www.cnblogs.com/zzjeny/p/5564400.html
- Bootstrap模态框按钮
1.触发模态框弹窗的代码 这里复制了一段Bootstrap模态框的代码 <h2>创建模态框(Modal)</h2> <!-- 按钮触发模态框 --> <but ...
- 解决bootstrap模态框内输入框无法获取焦点
bootstrap 模态框中的input标签在某些情况下会无法获取焦点. 最终解决方法:去除模态框的 tabindex="-1" 属性即可
- Bootstrap 模态框(Modal)插件
原文链接:http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html Bootstrap 模态框(Modal)插件 模态框(Modal)是覆 ...
- Bootstrap 模态框在用户点击背景空白处时会自动关闭
问题: Bootstrap 模态框在用户点击背景空白处时,会自动关闭. 解决方法: 在HTML页面中编写模态框时,在div初始化时添加属性 aria-hidden=”true” data-backdr ...
- Bootstrap模态框(MVC)
BZ这篇博客主要是为大家介绍一下MVC如何弹出模态框.本文如果有什么不对的地方,希望大神们多多指教,也希望和我一样的小菜多多学习.BZ在这里谢过各位. 首先要在页面加上一个点击事件: @Html.Ac ...
随机推荐
- Python 实现 Html 转 Markdown(支持 MathJax 数学公式)
因为需要转 html 到 markdown,找了个 python 的库,该库主要是利用正则表达式实现将 Html 转为 Markdown. 数学公式需要自己修改代码来处理. 我 fork 的项目地址: ...
- Linux haproxy配置参数
http-request option http-server-close option http-pretend-keepalive option httpclose option redispat ...
- 配置GitHub Push自动触发Jenkins的构建
这里以gitbook的项目为例,GitHub中的gitbook项目部署在Jenkins中,执行git push命令时自动执行Jenkins构建,其他项目只是最后的执行脚本不同 环境准备 安装Jenki ...
- cenos7上部署python3环境以及mysqlconnector2.1.5
本机的python2不要管他,因为可能有程序依赖目前的python2环境,比如yum!!!!! 一.安装python3依赖环境: yum -y install zlib-devel bzip2-dev ...
- pthread 线程立即取消的两种方法
1.相关函数介绍 a. int pthread_cancel(pthread_t thread) 1发送终止信号给thread线程,如果成功则返回0,否则为非0值.发送成功并不意味着thread会终止 ...
- Redis 高级部分
一.主从复制 image.png Rdis 的主从复制特点 image.png 1. 配置主从 实现方式同样有两种: 命令方式和配置文件方式 命令方式 只需要在从服务器上执行如下命令即可 sl ...
- Unity下载
Unity下载 Mac OS或Windows操作系统都可以使用对应的Unity版本进行开发 Unity引擎的官方网站:http://www.unity3d.com 官方下载地址:http://unit ...
- Python认识到放弃
基础入门 计算机硬件基础 变量 数据类型 基本运算符 变量常量 流程控制 数据类型 数字,字符串,列表 元组,字典,集合 字符编码 python2 python3 文件处理 文件读写 指针移动 函数 ...
- 关于Python常见功能使用的博客收藏
Python绘制曲面和曲面对应的等高线图: https://blog.csdn.net/weixin_40198632/article/details/78570679 python实现三维拟合 ht ...
- request redirection
# encoding:utf-8 import reimport jsonimport randomfrom esdapi.config import BASE_URLfrom requests.se ...