css transitions on new elements

后端 未结 3 2124
长情又很酷
长情又很酷 2020-12-01 05:03

I cannot find a way to use css transitions on newly created dom elements.

let\'s say I have an empty html document.



        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 05:59

    requestAnimationFrame() (https://developer.mozilla.org/en-US/docs/Web/API/window.requestAnimationFrame) appears to work across Firefox, Chrome and Safari. A more reliable, logical solution that setTimeout(). For older browsers (IE8), it will require a Polyfill (naturally, the transition won't occur, but the CSS will still change).

提交回复
热议问题