【发布时间】:2020-07-22 05:43:19
【问题描述】:
在 IE11 中测试这段代码!它是复杂页面的精简版,适用于除 IE11 以外的所有浏览器。我需要支持这个浏览器。
.theme-layout {
display: -webkit-box;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
flex-direction: column;
height: 100vh;
max-height: 100vh;
}
.theme-content {
-webkit-box-ordinal-group: 2;
order: 1;
width: 100%;
-webkit-box-flex: 1;
flex-grow: 1;
display: -webkit-box;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
flex-direction: row;
flex-wrap: nowrap;
-webkit-box-align: stretch;
align-items: stretch;
position: relative;
}
.theme-main {
flex-basis: 100%;
-webkit-box-ordinal-group: 3;
order: 2;
}
.composite-page {
padding-bottom: 7.5rem;
}
.composite-page-background {
margin: 0;
}
.composite-page-background picture {
position: fixed;
z-index: -1;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: -webkit-box;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
flex-direction: row;
flex-wrap: nowrap;
-webkit-box-align: stretch;
align-items: stretch;
}
.composite-page-background picture img {
-o-object-fit: cover;
object-fit: cover;
-o-object-position: 50% 50%;
object-position: 50% 50%;
width: 100%;
}
.composite-page-background picture:after {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(-10%, #0c6158), color-stop(60%, transparent));
background-image: linear-gradient(to bottom, #0c6158 -10%, transparent 60%);
}
.theme-paragraph-section {
height: calc(100vh - 7.5rem);
display: -webkit-box;
display: flex;
scroll-snap-align: start;
}
@media screen and (max-width: 768px) {
.theme-paragraph-section {
height: auto;
}
}
.theme-paragraph-section:target {
-webkit-animation: theme-paragraph-section-blink 1.3s;
animation: theme-paragraph-section-blink 1.3s;
}
@media (prefers-reduced-motion: reduce) {
.theme-paragraph-section:target {
-webkit-animation: none;
animation: none;
}
}
.theme-paragraph-section:before, .theme-paragraph-section:after {
content: "";
-webkit-box-flex: 1;
flex-grow: 1;
flex-shrink: 1;
flex-basis: calc(45rem / 2);
pointer-events: none;
}
<div class="theme-layout">
<div class="theme-content">
<main class="theme-main" id="main-content" role="main">
<div>
<div id="block-mainpagecontent">
<article class="composite-page">
<figure class="composite-page-background">
<picture>
<source media="(min-width: 1601px)" srcset="https://picsum.photos/id/1/1920/1080">
<source media="(min-width: 1381px)" srcset="https://picsum.photos/id/1/1600/900">
<source media="(min-width: 1181px)" srcset="https://picsum.photos/id/1/1380/777">
<source media="(min-width: 901px)" srcset="https://picsum.photos/id/1/1180/664">
<source media="(min-width: 611px)" srcset="https://picsum.photos/id/1/900/507">
<source media="(max-width: 610px)" srcset="https://picsum.photos/id/1/610/1084">
<img src="https://picsum.photos/id/1/900/507">
</picture>
</figure>
<div class="theme-paragraph-section" id="paragraph-45">
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
Dummy Content<br><br><br>
</div>
</article>
</div>
</div>
</main>
</div>
</div>
由于 stackoverflow 不再支持 IE11,我链接到一个 codepen 调试视图,您可以在 IE11 中打开它:https://cdpn.io/HerrSerker/debug/748ff2e947bdc668a7af47e6eeb0872a
此代码包含一个响应式图像,该图像应覆盖整个窗口并在滚动时保持固定。 在此图像之前分层的是一些虚拟内容,这些内容会强制页面可滚动。
现在的问题:当我在 Internet Explorer 11 中滚动时,背景中的固定图像不固定,而是上下跳跃,但只有当我使用鼠标滚轮或键盘滚动时( SPACE、UP、DN、PGUP 或 PGDN)。如果我拖动滚动条,固定元素会保持应有的固定状态。
【问题讨论】:
标签: css internet-explorer scroll css-position fixed