html - IE 11 伪元素::之前的绝对背景

标签 html css internet-explorer internet-explorer-11

我的问题很奇怪。我在 container::before 中有一个背景,绝对定位并且在每个浏览器上它都能完美运行。

在 IE 11 上,当我第一次加载我的页面时,我的背景只占我容器的宽度(两边都不可见)。当我打开我的调试器或当我移动窗口时,侧面会显露出来。

我试过了 this hack但它不起作用。

.connexion-layout {
    position: relative;
    overflow: hidden; 
}
.connexion-layout .container {
    padding-top: 200px;
    padding-bottom: 200px; 
}

.connexion-layout .container::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 0;
    background: none no-repeat center center / cover; 
}

@media screen and (min-width: 980px) {
    .connexion-layout .container::before {
        background-image: url("../../theme/images/connexion-bg-desktop.jpg?1433411383"); 
    } 
}
@media screen and (max-width: 979px) {
    .connexion-layout .container::before {
        background-image: url("../../theme/images/connexion-bg-mobile.jpg?1433411383"); 
    } 
}

你有过这样的经历吗?

最佳答案

向父级添加 position: relative; 为我修复了这个完全相同的错误。

关于html - IE 11 伪元素::之前的绝对背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31003798/

相关文章:

html - 表格行边框半径不起作用 - 替代方案?

javascript - Fullpage.js 不会在任何浏览器(chrome、firefox、edge)中滚动

javascript - 为什么 <h4> 和 <p> 元素中的文本没有一起出现?

javascript - 特殊风格-素材图标

javascript - 在 TextArea 中捕捉标签

javascript - 使用 JavaScript 使用透明图像创建可扩展叠加层

html - 如何在 UIWebView 中显示 HTML 代码?

javascript - 如何检查 Svelte 应用程序的浏览器兼容性?

css - 如何防止 JQueryUI 上下文菜单出现在 IE9 中加载到 IFrame 中的 PDF 下方

python - 测试失败后出现很多IEDriverServer.exe