Force DOM redraw/refresh on Chrome/Mac

前端 未结 24 1949
轻奢々
轻奢々 2020-11-22 02:11

Every once in a while, Chrome will render perfectly valid HTML/CSS incorrectly or not at all. Digging in through the DOM inspector is often enough to get it to realize the

24条回答
  •  误落风尘
    2020-11-22 03:00

    We recently encountered this and discovered that promoting the affected element to a composite layer with translateZ fixed the issue without needing extra javascript.

    .willnotrender { 
       transform: translateZ(0); 
    }
    

    As these painting issues show up mostly in Webkit/Blink, and this fix mostly targets Webkit/Blink, it's preferable in some cases. Especially since many JavaScript solutions cause a reflow and repaint, not just a repaint.

提交回复
热议问题