css - 显示固定 'modal' div 时的页面切换

标签 css modal-dialog marionette

所以我在 backbone.marionette 中构建了自己的自定义模态框,但我遇到了一个问题,即每次我 show() 模态时,我的页面都会向下移动大约半个英寸。很烦人。有人知道如何解决这个问题或解决这个问题吗?

这是我的 #modal.overlay CSS:

#modal {
    position: fixed;
    top: 0;
    left:0;
    right:0;
    margin-left:auto;
    margin-right:auto;
    z-index: 1002;
    width: 70%;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    z-index: 1001;
}

最佳答案

找到了一个解决方案 - 如果我将模态的 top 属性设置为 0 并给它一个 margin-top 任何东西,那么就没有了恼人的抵消。这是我最终使用的 CSS:

#modal {
    position: fixed;
    top: 0;
    left:0;
    right:0;
    margin-top: 2em;
    margin-left:auto;
    margin-right:auto;
    z-index: 1002;
    width: 70%;
}

关于css - 显示固定 'modal' div 时的页面切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21667276/

相关文章:

css - CSS 转换完成后运行函数

html - 页面对于窗口来说太大

c# - 将数据从一个表单传递到另一个表单

javascript - 如果跨度内有文本,为什么 Angular Material 模式对话框会展开?

javascript - 尝试使用 requirejs 实例化 Marionette 应用程序时出现“对象不是函数”错误

javascript - 带有 Backbone + Marionette 但没有 Rails 的 ECO 模板

python - 在pycharm中连接html文件和css文件

javascript - 交换 iframe src 以更改其中的视频

javascript - 使 CSS/Javascript 模态可滚动

backbone.js - 捕获 div 上的滚动事件