我的问题很奇怪。我在 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/