【发布时间】:2015-09-09 07:29:38
【问题描述】:
我的问题很奇怪。我有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");
}
}
你有过这样的经历吗?
【问题讨论】:
-
除非你有 Sass->CSS 编译问题,只发布编译后的 CSS。
-
你找到答案了吗?我有完全相同的东西!
-
除了静态之外,您总是需要在父元素上设置定位,否则它将使用第一个元素,直到到达主体。通常一个使用`position: relative;`
标签: html css internet-explorer internet-explorer-11