[英]Content inside scrollable div flickers in IE11 when I use transform translateY(0) in parent
Open the following link in IE11. 在IE11中打开以下链接。 Scroll down the viewport scrollbar to the middle of the page.
向下将视口滚动条向下滚动到页面中间。 Now scroll down the scrollable div(using mouse scroll).
现在向下滚动可滚动的div(使用鼠标滚动)。 You will find the scrollbar content flickers and goes above the scrollable div.
您会发现滚动条内容闪烁并且位于可滚动div上方。
And if I remove the transfrom properties from modal-dialog class or I disable smooth scrolling, it works fine. 而且,如果我从modal-dialog类中删除了transfrom属性,或者禁用了平滑滚动,则效果很好。
Can anyone please explain the reason of this flickering clearly?why does it work correctly if I remove transform properties from dialog? 任何人都可以清楚地解释此闪烁的原因吗?如果我从对话框中删除转换属性,为什么它可以正常工作? Here is codepen code link that-
这是代码笔代码链接-
HTML 的HTML
<div id="my-id" class="modal">
<div class="modal-dialog">
<div style="height: 250px; background-color: coral">Fill space</div>
<div class="container">
<div>Test Container</div>
<ul class="options" id="ddlTest">
</ul>
</div>
<div style="height: 600px; background-color: greenyellow">Fill space</div>
</div>
</div>
CSS 的CSS
.modal {
position: fixed;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
z-index: 1010;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
background: rgba(0, 0, 0, 0.6);
opacity: 1;
-webkit-transition: opacity 0.15s linear;
transition: opacity 0.15s linear;
touch-action: double-tap-zoom pinch-zoom cross-slide-y;
-webkit-transform: translateZ(0);
transform: translateZ(0px);
}
.modal-dialog {
position: relative;
box-sizing: border-box;
margin: 50px auto;
padding: 20px;
width: 600px;
max-width: 100%;
max-width: calc(100% - 20px);
background: #ffffff;
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0px);
border-radius: 3px;
}
.container .options {
position: relative;
overflow-x: hidden;
overflow-y: auto;
margin: 0 4px 4px 0;
padding: 0 0 0 4px;
max-height: 200px;
}
The fixed position style property on the outer div with class modal and id "my-id" seems to be the problem. 问题是外部div上具有类模态和id“ my-id”的固定位置样式属性。 When I toggle the position back to static the flickering stops.
当我将位置切换回静态时,闪烁停止。
At this point you can try setting the position to relative as it does not cause this flickering. 此时,您可以尝试将位置设置为相对,因为它不会引起闪烁。 To emulate fixed position you can add an eventListener to the body for "scroll" event and update the top (offset is any offset you choose):
要模拟固定位置,您可以向“滚动”事件的主体添加一个eventListener并更新顶部(偏移量是您选择的任何偏移量):
referenceToModalElement.style.top = (event.currentTarget.scrollTop || document.documentElement.scrollTop) + offset + "px";
do not forget to throttle the scroll event as it is fires rapidly. 不要忘记限制滚动事件,因为它会迅速触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.