在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,因此我链接到一个代码笔调试视图,您可以在IE11中打开该视图:https://cdpn.io/HerrSerker/debug/748ff2e947bdc668a7af47e6eeb0872a
此代码包含一个响应式图像,该图像应覆盖整个窗口并在滚动时保持固定。 在此图像之前分层的是一些伪造的内容,它们迫使页面可滚动。
现在出现问题:当我在Internet Explorer 11中滚动时,背景中的固定图像不是固定的,而是向上和向下跳跃,仅当我使用鼠标滚轮或键盘滚动时才会出现( SPACE , UP , DN , PGUP 或 PGDN )。如果拖动滚动条,则固定元素将保持应有的固定状态。