简体   繁体   English

当我在父级中使用transform translateY(0)时,可滚动div中的内容在IE11中闪烁

[英]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上方。

CodePen Page Link CodePen页面链接

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- 这是代码笔代码链接-

CodePen Code CodePen代码

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.

相关问题 IE11 - 滚动条闪烁 - IE11 - Scrollbar flickers 在 IE11 中不起作用的内容可编辑 div 中将插入符号移动到末尾 - Moving caret to the end in a content editable div not working in IE11 当我在IE11中显示其他内容时,如何通过单击其区域以外的区域隐藏当前内容? - How to hide current content by clicking outside its area, and when I show another content in IE11? IE11在AJS 1.3中闪烁,需要快速修复 - IE11 flickers in AJS 1.3 and need a quick fix 修复了标题表,在单击div滚动条图标点击时使用IE11(Internet Explorer)中的Jquery闪烁滚动。 - Fixed header Table, on scroll using Jquery flickers in IE11 (internet explorer) on click of div scroll bar icon click. 仅当我使用IE11时才会自动触发事件addUserSignedOut - The event addUserSignedOut is triggered automaticity only when i use IE11 一起使用onmousedown,onchange和onblur时IE11崩溃 - IE11 crashes when use onmousedown, onchange, onblur together 如何在IE11中使用TextEncoder? - How do I use TextEncoder in IE11? IE11:document.getSelection在IE11的输入(即文本)标签内无法正常工作 - IE11: document.getSelection not working properly inside Input (i.e. text) tags on IE11 JavaScript / IE11-清除DIV内容 - JavaScript/IE11 - Clearing DIV Contents
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM