javascript - 如何垂直居中引导模式?

标签 javascript css html twitter-bootstrap-3

我是新手。实际上,我已经尝试了所有的解决方案,所以,我问这个问题。

我的模型CSS是

#orphanModal{
  .modal-body{
    min-height: 450px;
    margin-bottom: 10px;
  }
  .modal-footer {
    margin: 0;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 400;
    background: #f1f1f1;
    border-top: 1px solid #e0e0e0;
    border-radius: 6px;
  }
  .modal-dialog{
    width: 700px;
  }
  .modal-close, .modal-close:hover{
    color: #000000;
    font-weight: bolder;
    font-size: 24px;
  }
  .modal-header{
    height: 60px;
  }
}

我的模型是我们从 bootstarp 站点获取的默认模型。 谁能告诉我我的 CSS 有什么问题吗?

我试过了

.modal-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) !important;
}

还有。但没有运气。谢谢。

最佳答案

要垂直对齐任何东西,在这种情况下是模态的,你可以这样做:

.modal{
  position: relative;
  top: 50;
  transform: translateY(-50%);
}

Notice: This will work if parent element have position relative.

这也会在您调整大小时对齐元素。

关于javascript - 如何垂直居中引导模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51535590/

相关文章:

javascript - 从 Google 表格导入数据不起作用

javascript - NodeJS 模块导出

javascript - 如何在 Mac 上设置 ReactJS?

javascript - 使用 momentJS 确定任意时区中指定日期的星期几

javascript - 为什么显示错误无法读取属性 'addEventListener'?

javascript - 在现有 div 上渲染 div

javascript - 为react-chartjs-2添加渐变背景

javascript - 你如何每秒加1?

javascript - 从数据库中提取数据并在模态中显示

python - 使用 Python 对 HTML 源代码进行标记和标记