css - 如何使用 CSS 垂直集中 Bootstrap V4 模态?

标签 css bootstrap-4 twitter-bootstrap-4

<分区>

我怎样才能集中 Bootstrap V4 modal用 CSS?

最佳答案

您可以像这样覆盖 .modal-dialog 的位置来垂直居中模态..

.modal.show .modal-dialog {
    -webkit-transform: translate(0,-50%);
    -o-transform: translate(0,-50%);
    transform: translate(0,-50%);
    top: 50%;
    margin: 0 auto;
}

http://www.codeply.com/go/14Ki1kyTgo

2018 年更新

从 Bootstrap 4 Beta 3 开始,有一个新的 modal-dialog-centered 类可以用来代替上述自定义方法。

https://www.codeply.com/go/lpOtIFoN6E (测试版 3)

关于css - 如何使用 CSS 垂直集中 Bootstrap V4 模态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42405989/

相关文章:

html - CSS 将列表文本移动到另一侧

html - 单击鼠标翻转卡片

jquery - 我无法在 Bootstrap 4 导航栏周围放置容器

reactjs - 提交 React 表单后,如何清除 Bootstrap 4 错误?

css - 移动浏览器在较小的屏幕尺寸(移动设备)上显示 768px+ 的断点样式

twitter-bootstrap - 在 Bootstrap 4 中显示单选按钮组的无效反馈文本

html - 对齐网页页眉中的组件

jquery - 禁用 DIV 中的所有 A(URL) 元素

html - 在移动设备上,如何在点击超链接时设置其样式?

html - Bootstrap 行 - 在小型设备上折叠时强制 div 的高度相同